﻿/// <reference path="../../../libs/highcharts/highcharts.js" />
//贯穿整个地图 开放封装
/*路径导航*/
/**
* 测量工具
**/
/**
* Created by 李鹏 on 2015/7/1.
*/
/*
*天气预报模型
*/
/**
* 地图对比
*/
function parseUrl(l) {
    var c = {};
    l = l.split("&");
    for (var m = 0; m < l.length; m++) {
        var g = l[m].indexOf("=");
        if (-1 != g) {
            var h = l[m].substring(0, g),
                g = l[m].substring(g + 1),
                g = decodeURIComponent(g);
            c[h.toUpperCase()] = g
        }
    }
    return c
}
function parseParam(l) {
    var c = [],
        m;
    for (m in l) c.push(m + "=" + l[m]);
    return c.join("&")
}
function isValid(l) {
    return null != l && "" != l ? !0 : !1
}
String.prototype.ClipStr = function (l) {
    null == l && (l = 14);
    l *= 2;
    for (var c = 0,
        m = 0; m < this.length && c < l; m++) this.charAt(m).match(/[^-ÿ]/ig) ? c += 2 : c += 1;
    return m < this.length ? this.substr(0, m - 2) + "..." : this
};
String.prototype.Trim = function () {
    return this.replace(/^\s+/g, "").replace(/\s+$/g, "")
};
var Clone = function (l) {
    var c;
    switch (typeof l) {
        case "undefined":
            break;
        case "string":
            c = l + "";
            break;
        case "number":
            c = l - 0;
            break;
        case "boolean":
            c = l;
            break;
        case "object":
            if (null === l) c = null;
            else if (l instanceof Array) {
                c = [];
                for (var m = 0,
                    g = l.length; m < g; m++) c.push(Clone(l[m]))
            } else for (m in c = {},
                l) c[m] = Clone(l[m]);
            break;
        default:
            c = l
    }
    return c
};
function Cookies() {
    this.get = function (l) {
        for (var c = document.cookie.split(";"), m = "", g = 0; g < c.length; g++) if (c[g].Trim().substr(0, l.length) == l) {
            m = c[g].Trim().substr(l.length + 1);
            break
        }
        return unescape(m)
    };
    this.getChild = function (l, c) {
        for (var m = this.get(l).split("&"), g = "", h = 0; h < m.length; h++) if (m[h].Trim().substr(0, c.length) == c) {
            g = m[h].Trim().substr(c.length + 1);
            break
        }
        return g
    };
    this.set = function (l, c, m, g, h) {
        var k = "";
        l && (k += l + "=" + escape(c) + ";");
        m && (k += "expires=" + m.toGMTString() + ";");
        g && (k += "domain=" + g + ";");
        h && (k += "path=" + h + ";");
        document.cookie = k
    };
    this.remove = function (l) {
        var c = new Date;
        c.setTime(c.getTime() - 1E7);
        this.set(l, "", c)
    }
}
function setCookie(l, c) {
    var m = new Date;
    m.setTime(m.getTime() + 864E5);
    document.cookie = l + "=" + escape(c) + ";expires=" + m.toGMTString() + ";path=/"
}
function getCookie(l) {
    var c;
    return (c = document.cookie.match(new RegExp("(^| )" + l + "=([^;]*)(;|$)"))) ? unescape(c[2]) : null
}
function delCookie(l) {
    var c = new Date;
    c.setTime(c.getTime() - 1E4);
    var m = getCookie(l);
    null != m && (document.cookie = l + "=" + escape(m) + ";expires=" + c.toGMTString() + ";path=/")
}
function string2xml(l) {
    var c = null;
    window.ActiveXObject ? (c = new ActiveXObject("Microsoft.XMLDOM"), c.loadXML(l)) : window.XMLHttpRequest && (c = (new DOMParser).parseFromString(l, "text/xml"));
    return c
}
Date.now || (Date.now = function () {
    return (new Date).valueOf()
});

//分页
var PageCtl = function () {
    function l(c, b) {
        var a, e = [];
        if (b < c && 1 < b) e.push("<li class='pageon pageprev'>上一页</li>"),
            e.push("<li class='pageon'>" + (b - 1) + "</li>"),
            e.push("<li class='pagenow'>" + b + "</li>"),
            e.push("<li class='pageon'>" + (b + 1) + "</li>"),
            3 == b ? e.splice(1, 0, "<li class='pageon'>1</li>") : 3 < b && e.splice(1, 0, "<li class='pageon'>1</li><li class='pagepot'>...</li>"),
            b == c - 2 ? e.push("<li class='pageon'>" + c + "</li>") : b < c - 2 && e.push("<li class='pagepot'>...</li><li class='pageon'>" + c + "</li>"),
            e.push("<li class='pageon pagenext'>下一页</li>");
        else if (1 == b) {
            e.push("<li class='pageoff'>上一页</li>");
            e.push("<li class='pagenow'>1</li>");
            if (5 > c) for (a = 1; a < c; a++) e.push("<li class='pageon'>" + (a + 1) + "</li>");
            else e.push("<li class='pageon'>2</li><li class='pageon'>3</li><li class='pagepot'>...</li><li class='pageon'>" + c + "</li>");
            1 == c ? e.push("<li class='pageoff'>下一页</li>") : e.push("<li class='pageon pagenext'>下一页</li>")
        } else {
            e.push("<li class='pageon pagenext'>上一页</li>");
            if (5 > c) for (a = 0; a < c - 1; a++) e.push("<li class='pageon'>" + (a + 1) + "</li>");
            else e.push("<li class='pageon'>1</li><li class='pagepot'>...</li>"),
                e.push("<li class='pageon'>" + (c - 2) + "</li><li class='pageon'>" + (c - 1) + "</li>");
            e.push("<li class='pagenow'>" + c + "</li>");
            e.push("<li class='pageoff'>下一页</li>")
        }
        $("#" + m + " .page").html(e.join(""))
    }
    var c = 0,
        m, g, h = 10;
    return {
        init: function (k, b, a) {
            m = k;
            a && (h = a);
            "function" == typeof b ? (g = b, $("#" + m).delegate(".pageon", "click",
                function (a) {
                    a = $(this).text();
                    var b = $("#" + m + " li.pagenow"),
                        b = 1 > b.length ? 1 : parseInt(b.text());
                    a = isNaN(a) ? "上一页" == a ? b - 1 : b + 1 : parseInt(a);
                    l(c, a);
                    g(a, h)
                })) : console.log && console.log("初始化失败！")
        },
        doPage: function (k, b) {
            null != b && (c = Math.ceil(b / h));
            l(c, k);
            g(k, h)
        },
        startEnd: function (c, b) {
            var a = (c - 1) * h;
            return [a, a + h >= b ? b : a + h]
        }
    }
},
    Browser = function () {
        var l = navigator.userAgent.toLowerCase(),
            c = window.opera,
            m = {
                ie: /(msie\s|trident.*rv:)([\w.]+)/.test(l),
                opera: !!c && c.version,
                webkit: -1 < l.indexOf(" applewebkit/"),
                mac: -1 < l.indexOf("macintosh"),
                quirks: "BackCompat" == document.compatMode
            };
        m.gecko = "Gecko" == navigator.product && !m.webkit && !m.opera && !m.ie;
        var g = 0;
        if (m.ie) {
            var g = l.match(/(?:msie\s([\w.]+))/),
                h = l.match(/(?:trident.*rv:([\w.]+))/),
                g = g && h && g[1] && h[1] ? Math.max(1 * g[1], 1 * h[1]) : g && g[1] ? 1 * g[1] : h && h[1] ? 1 * h[1] : 0;
            m.ie11Compat = 11 == document.documentMode;
            m.ie9Compat = 9 == document.documentMode;
            m.ie10Compat = 10 == document.documentMode;
            m.ie8 = !!document.documentMode;
            m.ie8Compat = 8 == document.documentMode;
            m.ie7Compat = 7 == g && !document.documentMode || 7 == document.documentMode;
            m.ie6Compat = 7 > g || m.quirks;
            m.ie9above = 8 < g;
            m.ie9below = 9 > g
        }
        m.gecko && (h = l.match(/rv:([\d\.]+)/)) && (h = h[1].split("."), g = 1E4 * h[0] + 100 * (h[1] || 0) + 1 * (h[2] || 0));
        /chrome\/(\d+\.\d)/i.test(l) && (m.chrome = +RegExp.$1);
        /(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(l) && !/chrome/i.test(l) && (m.safari = +(RegExp.$1 || RegExp.$2));
        m.opera && (g = parseFloat(c.version()));
        m.webkit && (g = parseFloat(l.match(/ applewebkit\/(\d+)/)[1]));
        m.version = g;
        return m
    }(),
    WebHost = window.location.host,
    inProxy = "../MapService/proxy.ashx?",
    DynamicLoading = DynamicLoading || {
        css: function (l, c) {
            if (!l || 0 === l.length) throw Error('argument "path" is required !');
            c || (c = window);
            var m = c.document.getElementsByTagName("head")[0],
                g = c.document.createElement("link");
            g.href = l;
            g.rel = "stylesheet";
            g.type = "text/css";
            m.appendChild(g)
        },
        js: function (l, c) {
            if (!l || 0 === l.length) throw Error('argument "path" is required !');
            c || (c = window);
            var m = c.document.getElementsByTagName("head")[0],
                g = c.document.createElement("script");
            g.src = l;
            g.type = "text/javascript";
            m.appendChild(g);
        }
    };
$(function () {
    SetCalcValue()
});
$(window).resize(function () {
    SetCalcValue()
});
function SetCalcValue() {
    $("[data-calc-height]").each(function () {
        var l = $(this),
            c = l.parent(),
            m = l.attr("data-calc-height");
        l.height(GetCalcValue(m, c.height()))
    });
    $("[data-calc-width]").each(function () {
        var l = $(this),
            c = l.parent(),
            m = l.attr("data-calc-width");
        l.width(GetCalcValue(m, c.width()))
    });
    $("[data-calc-left]").each(function () {
        var l = $(this),
            c = l.parent(),
            m = l.attr("data-calc-left");
        l.css("left", GetCalcValue(m, c.width()) + "px")
    })
}
function GetCalcValue(l, c) {
    var m = l.split("-");
    return .01 * c * parseInt(m[0].replace("%")) - parseFloat(m[1])
}
window.Util || (window.Util = {});
window.Util.MD5 || (window.Util.MD5 = function (l) {
    function c(a) {
        str = "";
        for (j = 0; 3 >= j; j++) str += "0123456789abcdef".charAt(a >> 8 * j + 4 & 15) + "0123456789abcdef".charAt(a >> 8 * j & 15);
        return str
    }
    function m(a, b) {
        var e = (a & 65535) + (b & 65535);
        return (a >> 16) + (b >> 16) + (e >> 16) << 16 | e & 65535
    }
    function g(a, b, f, d, c, h) {
        a = m(m(b, a), m(d, h));
        return m(a << c | a >>> 32 - c, f)
    }
    function h(a, b, f, d, c, h, n) {
        return g(b & f | ~b & d, a, b, c, h, n)
    }
    function k(a, b, f, d, c, h, n) {
        return g(b & d | f & ~d, a, b, c, h, n)
    }
    function b(a, b, f, d, c, h, n) {
        return g(f ^ (b | ~d), a, b, c, h, n)
    }
    return function (a) {
        nblk = (a.length + 8 >> 6) + 1;
        blks = Array(16 * nblk);
        for (i = 0; i < 16 * nblk; i++) blks[i] = 0;
        for (i = 0; i < a.length; i++) blks[i >> 2] |= a.charCodeAt(i) << i % 4 * 8;
        blks[i >> 2] |= 128 << i % 4 * 8;
        blks[16 * nblk - 2] = 8 * a.length;
        x = blks;
        a = 1732584193;
        var e = -271733879,
            f = -1732584194,
            d = 271733878;
        for (i = 0; i < x.length; i += 16) {
            var l = a,
                t = e,
                n = f,
                w = d;
            a = h(a, e, f, d, x[i + 0], 7, -680876936);
            d = h(d, a, e, f, x[i + 1], 12, -389564586);
            f = h(f, d, a, e, x[i + 2], 17, 606105819);
            e = h(e, f, d, a, x[i + 3], 22, -1044525330);
            a = h(a, e, f, d, x[i + 4], 7, -176418897);
            d = h(d, a, e, f, x[i + 5], 12, 1200080426);
            f = h(f, d, a, e, x[i + 6], 17, -1473231341);
            e = h(e, f, d, a, x[i + 7], 22, -45705983);
            a = h(a, e, f, d, x[i + 8], 7, 1770035416);
            d = h(d, a, e, f, x[i + 9], 12, -1958414417);
            f = h(f, d, a, e, x[i + 10], 17, -42063);
            e = h(e, f, d, a, x[i + 11], 22, -1990404162);
            a = h(a, e, f, d, x[i + 12], 7, 1804603682);
            d = h(d, a, e, f, x[i + 13], 12, -40341101);
            f = h(f, d, a, e, x[i + 14], 17, -1502002290);
            e = h(e, f, d, a, x[i + 15], 22, 1236535329);
            a = k(a, e, f, d, x[i + 1], 5, -165796510);
            d = k(d, a, e, f, x[i + 6], 9, -1069501632);
            f = k(f, d, a, e, x[i + 11], 14, 643717713);
            e = k(e, f, d, a, x[i + 0], 20, -373897302);
            a = k(a, e, f, d, x[i + 5], 5, -701558691);
            d = k(d, a, e, f, x[i + 10], 9, 38016083);
            f = k(f, d, a, e, x[i + 15], 14, -660478335);
            e = k(e, f, d, a, x[i + 4], 20, -405537848);
            a = k(a, e, f, d, x[i + 9], 5, 568446438);
            d = k(d, a, e, f, x[i + 14], 9, -1019803690);
            f = k(f, d, a, e, x[i + 3], 14, -187363961);
            e = k(e, f, d, a, x[i + 8], 20, 1163531501);
            a = k(a, e, f, d, x[i + 13], 5, -1444681467);
            d = k(d, a, e, f, x[i + 2], 9, -51403784);
            f = k(f, d, a, e, x[i + 7], 14, 1735328473);
            e = k(e, f, d, a, x[i + 12], 20, -1926607734);
            a = g(e ^ f ^ d, a, e, x[i + 5], 4, -378558);
            d = g(a ^ e ^ f, d, a, x[i + 8], 11, -2022574463);
            f = g(d ^ a ^ e, f, d, x[i + 11], 16, 1839030562);
            e = g(f ^ d ^ a, e, f, x[i + 14], 23, -35309556);
            a = g(e ^ f ^ d, a, e, x[i + 1], 4, -1530992060);
            d = g(a ^ e ^ f, d, a, x[i + 4], 11, 1272893353);
            f = g(d ^ a ^ e, f, d, x[i + 7], 16, -155497632);
            e = g(f ^ d ^ a, e, f, x[i + 10], 23, -1094730640);
            a = g(e ^ f ^ d, a, e, x[i + 13], 4, 681279174);
            d = g(a ^ e ^ f, d, a, x[i + 0], 11, -358537222);
            f = g(d ^ a ^ e, f, d, x[i + 3], 16, -722521979);
            e = g(f ^ d ^ a, e, f, x[i + 6], 23, 76029189);
            a = g(e ^ f ^ d, a, e, x[i + 9], 4, -640364487);
            d = g(a ^ e ^ f, d, a, x[i + 12], 11, -421815835);
            f = g(d ^ a ^ e, f, d, x[i + 15], 16, 530742520);
            e = g(f ^ d ^ a, e, f, x[i + 2], 23, -995338651);
            a = b(a, e, f, d, x[i + 0], 6, -198630844);
            d = b(d, a, e, f, x[i + 7], 10, 1126891415);
            f = b(f, d, a, e, x[i + 14], 15, -1416354905);
            e = b(e, f, d, a, x[i + 5], 21, -57434055);
            a = b(a, e, f, d, x[i + 12], 6, 1700485571);
            d = b(d, a, e, f, x[i + 3], 10, -1894986606);
            f = b(f, d, a, e, x[i + 10], 15, -1051523);
            e = b(e, f, d, a, x[i + 1], 21, -2054922799);
            a = b(a, e, f, d, x[i + 8], 6, 1873313359);
            d = b(d, a, e, f, x[i + 15], 10, -30611744);
            f = b(f, d, a, e, x[i + 6], 15, -1560198380);
            e = b(e, f, d, a, x[i + 13], 21, 1309151649);
            a = b(a, e, f, d, x[i + 4], 6, -145523070);
            d = b(d, a, e, f, x[i + 11], 10, -1120210379);
            f = b(f, d, a, e, x[i + 2], 15, 718787259);
            e = b(e, f, d, a, x[i + 9], 21, -343485551);
            a = m(a, l);
            e = m(e, t);
            f = m(f, n);
            d = m(d, w)
        }
        return c(a) + c(e) + c(f) + c(d)
    }(l)
});
var Service = function () {
    return {
        LS: "../MapService/proxy.ashx?http://www.sdmap.gov.cn/QueryService.ashx?city=" + encodeURIComponent("全国") + "&output=json&resultmode=255&uid=navinfo&st=LocalSearch&",
        LSID: "http://124.128.48.210:9001/service/SERVICE?city=全国&st=Obtain&output=json&resultmode=255&uid=navinfo&",
        PATH: "http://www.sdmap.gov.cn/SDPathService.ashx?st=RC&output=json&sl=0&uid=navinfo&",
        RGC2: "http://www.sdmap.gov.cn/GeoDecodeService.ashx?st=Rgc2&output=json&",
        jXS: "test?city=" + encodeURIComponent("全国") + "&output=json&resultmode=255&uid=navinfo&st=LocalSearch&",
        CorrectDir: "../correct/",
        basemap: [{
            group: "vec",
            name: "天地图-矢量",
            url: "http://t0.tianditu.com/vec_c/wmts",
            layer: "vec",
            style: "default",
            matrixSet: "c",
            format: "tiles",
            open: !0,
            maxlevel: 10
        },
        {
            group: "vec_n",
            name: "天地图-矢量注记",
            url: "http://t0.tianditu.com/cva_c/wmts",
            layer: "cva",
            style: "default",
            matrixSet: "c",
            format: "tiles",
            open: !0,
            maxlevel: 10
        },
        {
            group: "vec",
            name: "山东矢量地图",
            url: "http://www.sdmap.gov.cn/tileservice/SDPubMap",
            layer: "sdvec",
            style: "default",
            matrixSet: "c",
            format: "image/png",
            open: !0,
            minlevel: 7
        },
        {
            group: "img",
            name: "天地图-影像地图",
            url: "http://t0.tianditu.com/img_c/wmts",
            layer: "img",
            style: "default",
            matrixSet: "c",
            format: "tiles",
            open: !1,
            maxlevel: 10
        },
        {
            group: "img",
            name: "山东影像2017",
            url: "http://www.sdmap.gov.cn/tileservice/SdRasterPubMap",
            layer: "sdimg2017",
            style: "default",
            matrixSet: "img2017",
            format: "image/png",
            open: !1,
            minlevel: 7
        },
        {
            group: "img_n",
            name: "天地图-影像注记",
            url: "http://t0.tianditu.com/cia_c/wmts",
            layer: "cia",
            style: "default",
            matrixSet: "c",
            format: "tiles",
            open: !1,
            maxlevel: 6
        },
        {
            group: "img_n",
            name: "山东影像注记",
            url: "http://www.sdmap.gov.cn/tileservice/SDRasterPubMapDJ",
            layer: "sdcia",
            style: "default",
            matrixSet: "sdcia",
            format: "image/png",
            open: !1,
            minlevel: 7
        }],
        DOWNLOAD: "../MapService/proxy.ashx?http://www.sdmap.gov.cn:8081/KZDService/Handler/NEWTDTPlotsHandler.ashx",
        UserPlot: "../MapService/proxy.ashx?http://www.sdmap.gov.cn:8081/biaohui_new/Handler1.ashx",
        GETUserPlot: "http://www.sdmap.gov.cn/SDMapService/MySpace.svc/GetUserPlots?t=1",
        CityBound: "../MapService/proxy.ashx?http://www.sdmap.gov.cn/cityExtentSearch/cityExtentSearch.asmx/getBoundary?",
        CitySearch: "../MapService/proxy.ashx?http://www.sdmap.gov.cn/cityExtentSearch/cityExtentSearch.asmx/getDistrict?",
        POITILE: "../MapService/proxy.ashx?http://www.sdmap.gov.cn/tileservice/sdpoi?service=poi&request=getpoi&tileMatrixSet=sss&format=text/html",
        IMGMETA: "http://sdgt.sdmap.gov.cn/imgmeta/QueryMeta.ashx?",
        NCM: ["vec", "cva", "img", "cia", "sdcia"],
        RTService: "http://www.sdmap.gov.cn/RTService/RTService.ashx?",
        RTServiceL: "test2?",
    }
}(),
    PoiInfoPop = function () {
        function l(a) {
            if ("ok" == a.status && (a = a.result)) {
                var b = String(a.district_text).split(">").join("").replace("市辖区", "").replace("山东省", ""),
                    e = "";
                a.road && "" != a.road.name && (e = a.road.name);
                var d = "";
                a.address && (d = a.address);
                a.point && "" != a.point.name ? $("#markName").text(a.point.name + "附近") : $("#markName").text(b + e);
                $("#right_pointNameInfo").html("<div id='address'>地址:" + b + e + d + "</div>");
                f.updateSize()
            }
        }
        function c(a) {
            var b = $("#tabs>ul:eq(0)").offset();
            $("#poiSearch_suglist").empty().append(a).show().css({
                left: b.left + 45 + "px",
                top: b.top + 65 + "px"
            }).children("div").click(h)
        }
        function m() {
            $("#pointFromText").keyup(function (a) {
                (a = $(this).val()) && WholeSearch.request("list", {
                    words: a
                },
                    c)
            });
            $("#pointToText").keyup(function (a) {
                (a = $(this).val()) && WholeSearch.request("list", {
                    words: a
                },
                    c)
            });
            $("#pointFromButton").click(function () {
                a.attributes = {
                    name: $("#markName").text()
                };
                PathSearch.setStart(d, 3);
                PathSearch.setEnd(a, 3)
            });
            $("#pointToButton").click(function () {
                a.attributes = {
                    name: $("#markName").text()
                };
                PathSearch.setStart(a, 3);
                PathSearch.setEnd(d, 3)
            });
            $("#pointPopupSearchBtn").click(function () {
                $("#left_query_text").val(a.attributes.name);
                var b = $("#pointSearch").val();
                if (b) {
                    switchSearch("s2");
                    var e = a.geometry,
                        n = parseInt($("#selectRadius").val()),
                        d = "POINT(" + e.x + " " + e.y + ")",
                        f = {};
                    a.attributes.geometry && (f = g(a.attributes.geometry, n), d = -1 < a.attributes.geometry.indexOf("POLYGON") ? f.bufwkt : f.orgwkt);
                    WholeSearch.request("buffer", {
                        words: b,
                        radius: n,
                        area: d,
                        mode: 1,
                        pagecap: 100
                    });
                    PoiInfoPop.close();
                    a.attributes.geometry ? DragMoveCtl.creatbuffer(f.buffea) : DragMoveCtl.setCircle(e, n)
                }
            });
            $("#tabs3 > .pointPopupBtn").click(function () {
                $("#left_query_text").val(a.attributes.name);
                var b = $(this).attr("code");
                switchSearch("s2");
                var e = a.geometry,
                    d = parseInt($("#selectRadius").val()),
                    f = "POINT(" + e.x + " " + e.y + ")",
                    c = {};
                a.attributes.geometry && (c = g(a.attributes.geometry, d), f = -1 < a.attributes.geometry.indexOf("POLYGON") ? c.bufwkt : c.orgwkt);
                WholeSearch.request("buffer", {
                    "class": b,
                    radius: d,
                    area: f,
                    mode: 1,
                    pagecap: 100
                });
                PoiInfoPop.close();
                a.attributes.geometry ? DragMoveCtl.creatbuffer(c.buffea) : DragMoveCtl.setCircle(e, d)
            });
            $("#poi_correct").click(function () {
                var b = a.attributes;
                MapCorrect.openCorrect(b.lsid ? {
                    TYPE: 1,
                    LSID: b.lsid
                } : {
                        NAME: b.name,
                        ADDR: b.address,
                        TELE: b.telephone,
                        CATG: b.catg,
                        TYPE: 3,
                        FID: b.id,
                        SRC: 1,
                        LNG: a.geometry.x,
                        LAT: a.geometry.y
                    })
            })
        }
        function g(a, b) {
            var e = {},
                d = new OpenLayers.Format.WKT,
                f = new OpenLayers.Format.GeoJSON,
                c = d.read(a),
                c = f.write(c),
                c = turf.buffer(JSON.parse(c), 6.2137E-4 * b, "miles"),
                f = f.read(c),
                d = d.write(f);
            e.orgwkt = a.replace("((", "(").replace("))", ")");
            e.buffea = f;
            e.bufwkt = d.replace("((", "(").replace("))", ")");
            return e
        }
        function h() {
            var a = $(this).attr("crd").split(";");
            d = new Ol2.Feature.Vector(new Ol2.Geometry.Point(parseFloat(a[0]), parseFloat(a[1])));
            a = a[3];
            d.attributes = {
                name: a
            };
            $("#tabs>div:visible :text").val(a);
            $("#poiSearch_suglist").hide()
        }
        function k() {//关闭弹出框
            b.unSelect();
            f && b.map.removePopup(f);
            DragMoveCtl.clear();
            //关闭轨迹
            if (graphicLayer != null) {
                graphicLayer.removeAllFeatures();
            }
        }
        var b, a, e = !1,
            f, d;
        return {
            init: function (a) {
                e || (b = a, 0 == $("#poiSearch_suglist").length && ($(document.body).append("<div id='poiSearch_suglist' style='position:absolute;display:none;'></div>"), $("#poiSearch_suglist").delegate("a", "click",
                    function () {
                        $("#poiSearch_suglist").hide()
                    })), DragMoveCtl.init(b.map, WholeSearch.request), e = !0)
            },
            show: function (e, d, c, h) {
                d = new Ol2.LonLat(d.lon || d.x, d.lat || d.y);
                var n;
                null != f && b.map.removePopup(f);

                if (c.type != "" && c.type != null) {
                    e = c.type;
                }

                switch (e) {
                    case "local":

                        f = new Ol2.Popup.FramedCloud("搜索", d, null, '<div id="poi_pop_info" style = "min-height:90px;width:333px;font-size:12px;"><div id = "mark_title"><div id="markName" style="padding-left:10px;font-size:14px;color:#3b9cfe;font-weight:700;margin-top:-2px;"></div></div><div id = "pointPopupContent" style = "margin-top:10px;display:block"><div id="right_pointNameInfo" style="margin-left: 10px;"></div></div></div>', null, !0, k);
                        b.map.addPopup(f);
                        n = [];
                        "" == c.address || c.geometry || n.push("<div id='address'>地址:" + c.address + "</div>");
                        "" == c.telephone || c.geometry || n.push("<div id='phone'>户数:" + c.house_holds + " <span>人数:" + c.person_num + "</span></div>");
                        "" == c.content || c.geometry || n.push("<div id='phone' title='" + c.content + "' >介绍:<textarea id=\"TextArea1\" rows=\"7\" cols=\"45\">" + c.content + "</textarea></div>");
                        if (c.geometry && -1 < c.geometry.indexOf("LINESTRING")) {
                            e = c.lsid.split(",");
                            h = [];
                            for (var q = 0; q < e.length; q++) h.push("实体码%3D%27" + e[q] + "%27");
                            url = "http://124.128.48.217:6080/arcgis/rest/services/gjfx/MapServer/0/query?where=" + h.join("+or+") + "&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=穿越地市名%2C穿越地市数%2C穿越县区数%2C穿越县区名&returnGeometry=false&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=pjson"
                        }
                        $("#right_pointNameInfo").append(n.join(""));
                        $("#pointPopupContent").append('<div id="tabs"><ul><li id="tabs-li1"><a href="#tabs1" class=""><img src="../Content/Map/images/blank.gif">到这里去    </a></li><li id="tabs-li2"><a href="#tabs2"><img src="../Content/Map/images/blank.gif">从这里出发    </a></li><li id="tabs-li3"><a href="#tabs3" class="selected"><img src="../Content/Map/images/blank.gif">周边搜索    </a></li></ul><div id="tabs1" class="pointTabDiv" style="display: none;"><span style="margin-right:4px;">起点</span><input type="text" id="pointFromText"><input type="button" id="pointFromButton" class="btnSmall" style="margin:-5px 0 0 10px" value="驾车"></div><div id="tabs2" style="display: none;"><span style="margin-right:4px;">终点</span><input type="text" id="pointToText"><input type="button" id="pointToButton" class="btnSmall" style="margin:-5px 0 0 10px" value="驾车"></div><div id="tabs3" style="display: block;"><input type="button" class="pointPopupBtn" code="5080 5082:5085 5380 5501 5502 5400" value="宾馆"><input type="button" class="pointPopupBtn" code="A180:A192 A195:A19C" value="银行"><input type="button" class="pointPopupBtn" code="7200 7203:7206 7280 7281 7500" value="医院"><input type="text" id="pointSearch" style="width:80px"><select name="selectAge" id="selectRadius" style="height:23px;margin-left:2px;border: #b3b3b3 solid 1px;"><option value="500">500米</option><option value="800">800米</option><option value="1000">1000米</option><option value="2000">2000米</option><option value="5000">5000米</option></select><input type="button" value="搜索" id="pointPopupSearchBtn" class="btnSmall" style="margin:-5px 0 0 4px"></div></div>');
                        //$("#mark_title").append("<div id='poi_correct' title='纠错'></div>");
                        $("#poi_pop_info").css({
                            width: "333px"
                        });
                        $("#markName").text(c.name);

                        break;
                    case "patrolman":

                        f = new Ol2.Popup.FramedCloud("搜索", d, null, '<div id="poi_pop_info" style = "min-height:90px;width:333px;font-size:12px;"><div id = "mark_title"><div id="markName" style="padding-left:10px;font-size:14px;color:#3b9cfe;font-weight:700;margin-top:-2px;"></div></div><div id = "pointPopupContent" style = "margin-top:10px;display:block"><div id="right_pointNameInfo"></div></div></div>', null, !0, k);
                        b.map.addPopup(f);
                        n = [];
                        "" == c.address || c.geometry || n.push("<div id='address'>地址:" + c.address + "</div>");
                        "" == c.telephone || c.geometry || n.push("<div id='phone'>电话:" + c.telephone + "</div>");

                        if (c.UserType == "非群众") {
                            "" == c.telephone || c.geometry || n.push("<div id='guiji'><a href='javascript:' onclick='showGuiJi(" + c.id + ")'>查看巡查轨迹</a></div>");
                        }

                        if (c.geometry && -1 < c.geometry.indexOf("LINESTRING")) {
                            e = c.lsid.split(",");
                            h = [];
                            for (var q = 0; q < e.length; q++) h.push("实体码%3D%27" + e[q] + "%27");
                            url = "http://124.128.48.217:6080/arcgis/rest/services/gjfx/MapServer/0/query?where=" + h.join("+or+") + "&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=穿越地市名%2C穿越地市数%2C穿越县区数%2C穿越县区名&returnGeometry=false&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=pjson"
                        }
                        $("#right_pointNameInfo").append(n.join(""));
                        $("#pointPopupContent").append('<div id="tabs"><ul><li id="tabs-li1"><a href="#tabs1" class=""><img src="../Content/Map/images/blank.gif">到这里去    </a></li><li id="tabs-li2"><a href="#tabs2"><img src="../Content/Map/images/blank.gif">从这里出发    </a></li><li id="tabs-li3"><a href="#tabs3" class="selected"><img src="../Content/Map/images/blank.gif">周边搜索    </a></li></ul><div id="tabs1" class="pointTabDiv" style="display: none;"><span style="margin-right:4px;">起点</span><input type="text" id="pointFromText"><input type="button" id="pointFromButton" class="btnSmall" style="margin:-5px 0 0 10px" value="驾车"></div><div id="tabs2" style="display: none;"><span style="margin-right:4px;">终点</span><input type="text" id="pointToText"><input type="button" id="pointToButton" class="btnSmall" style="margin:-5px 0 0 10px" value="驾车"></div><div id="tabs3" style="display: block;"><input type="button" class="pointPopupBtn" code="5080 5082:5085 5380 5501 5502 5400" value="宾馆"><input type="button" class="pointPopupBtn" code="A180:A192 A195:A19C" value="银行"><input type="button" class="pointPopupBtn" code="7200 7203:7206 7280 7281 7500" value="医院"><input type="text" id="pointSearch" style="width:80px"><select name="selectAge" id="selectRadius" style="height:23px;margin-left:2px;border: #b3b3b3 solid 1px;"><option value="500">500米</option><option value="800">800米</option><option value="1000">1000米</option><option value="2000">2000米</option><option value="5000">5000米</option></select><input type="button" value="搜索" id="pointPopupSearchBtn" class="btnSmall" style="margin:-5px 0 0 4px"></div></div>');
                        $("#poi_pop_info").css({
                            width: "333px"
                        });
                        $("#markName").text(c.name);

                        break;
                    case "specialpeople":

                        f = new Ol2.Popup.FramedCloud("搜索", d, null, '<div id="poi_pop_info" style = "min-height:90px;width:333px;font-size:12px;"><div id = "mark_title"><div id="markName" style="padding-left:10px;font-size:14px;color:#3b9cfe;font-weight:700;margin-top:-2px;"></div></div><div id = "pointPopupContent" style = "margin-top:10px;display:block"><div id="right_pointNameInfo"></div></div></div>', null, !0, k);
                        b.map.addPopup(f);
                        n = [];

                        var data = c.specialPersonViewModel;

                        "" == c.telephone || c.geometry || n.push("<div id='phone'>性别：" + data.SexName + "</div>");
                        "" == c.telephone || c.geometry || n.push("<div id='phone'>民族：" + data.NationName + "</div>");
                        "" == c.telephone || c.geometry || n.push("<div id='phone'>特殊人群类型：" + data.PersonTypeName + "</div>");
                        "" == c.telephone || c.geometry || n.push("<div id='phone'>电话号码：" + c.telephone + "</div>");
                        "" == c.telephone || c.geometry || n.push("<div id='phone'>健康状况：" + data.HealthName + "</div>");
                        "" == c.telephone || c.geometry || n.push("<div id='phone'>政治面貌：" + data.PoliticsName + "</div>");
                        "" == c.telephone || c.geometry || n.push("<div id='phone'>文化程度：" + data.CultureName + "</div>");
                        "" == c.telephone || c.geometry || n.push("<div id='phone'>身份证号：" + data.IDCard + "</div>");
                        "" == c.address || c.geometry || n.push("<div id='address'>地址：" + c.address + "</div>");
                        if (c.geometry && -1 < c.geometry.indexOf("LINESTRING")) {
                            e = c.lsid.split(",");
                            h = [];
                            for (var q = 0; q < e.length; q++) h.push("实体码%3D%27" + e[q] + "%27");
                            url = "http://124.128.48.217:6080/arcgis/rest/services/gjfx/MapServer/0/query?where=" + h.join("+or+") + "&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=穿越地市名%2C穿越地市数%2C穿越县区数%2C穿越县区名&returnGeometry=false&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=pjson"
                        }
                        $("#right_pointNameInfo").append(n.join(""));
                        $("#pointPopupContent").append('<div id="tabs"><ul><li id="tabs-li1"><a href="#tabs1" class=""><img src="../Content/Map/images/blank.gif">到这里去    </a></li><li id="tabs-li2"><a href="#tabs2"><img src="../Content/Map/images/blank.gif">从这里出发    </a></li><li id="tabs-li3"><a href="#tabs3" class="selected"><img src="../Content/Map/images/blank.gif">周边搜索    </a></li></ul><div id="tabs1" class="pointTabDiv" style="display: none;"><span style="margin-right:4px;">起点</span><input type="text" id="pointFromText"><input type="button" id="pointFromButton" class="btnSmall" style="margin:-5px 0 0 10px" value="驾车"></div><div id="tabs2" style="display: none;"><span style="margin-right:4px;">终点</span><input type="text" id="pointToText"><input type="button" id="pointToButton" class="btnSmall" style="margin:-5px 0 0 10px" value="驾车"></div><div id="tabs3" style="display: block;"><input type="button" class="pointPopupBtn" code="5080 5082:5085 5380 5501 5502 5400" value="宾馆"><input type="button" class="pointPopupBtn" code="A180:A192 A195:A19C" value="银行"><input type="button" class="pointPopupBtn" code="7200 7203:7206 7280 7281 7500" value="医院"><input type="text" id="pointSearch" style="width:80px"><select name="selectAge" id="selectRadius" style="height:23px;margin-left:2px;border: #b3b3b3 solid 1px;"><option value="500">500米</option><option value="800">800米</option><option value="1000">1000米</option><option value="2000">2000米</option><option value="5000">5000米</option></select><input type="button" value="搜索" id="pointPopupSearchBtn" class="btnSmall" style="margin:-5px 0 0 4px"></div></div>');
                        $("#poi_pop_info").css({
                            width: "333px"
                        });
                        $("#markName").text(c.name);

                        break;
                    case "basicPerson"://实有房屋、人口

                        f = new Ol2.Popup.FramedCloud("搜索", d, null, '<div id="poi_pop_info" style = "min-height:90px;width:333px;font-size:12px;"><div id = "mark_title"><div id="markName" style="padding-left:10px;font-size:14px;color:#3b9cfe;font-weight:700;margin-top:-2px;"></div></div><div id = "pointPopupContent" style = "margin-top:10px;display:block"><div id="right_pointNameInfo" style="margin-left: 10px;"></div></div></div>', null, !0, k);
                        b.map.addPopup(f);
                        n = [];

                        var data = c.basicPersonViewModel;

                        "" == data.address || c.geometry || n.push("<div id='address' style='overflow: hidden;'><div style='width: 155px;float: left;'><span style='display: inline-block;width: 64px;text-align: right;letter-spacing: 11px;'>姓名:</span><span>" + data.Name + "</span></div><div style='width: 155px;float: right;'><span style='display: inline-block;width: 64px;text-align: right;letter-spacing: 11px;'>性别:</span><span>" + data.SexName + "</span></div></div>");
                        "" == c.address || c.geometry || n.push("<div id='address' style='overflow: hidden;'><div style='width: 155px;float: left;'><span style='display: inline-block;width: 64px;text-align: right;letter-spacing: 11px;'>乡镇:</span><span>" + data.TownTitle + "</span></div><div style='width: 155px;float: right;'><span style='display: inline-block;width: 64px;text-align: right;letter-spacing: 11px;'>社区:</span><span>" + data.AreaTitle + "</span></div></div>");
                        "" == c.address || c.geometry || n.push("<div id='address' style='overflow: hidden;'><div style='width: 155px;float: left;'><span style='display: inline-block;width: 64px;text-align: right;letter-spacing: 11px;'>村庄:</span><span>" + data.VillageTitle + "</span></div><div style='width: 155px;float: right;'><span style='display: inline-block;width: 64px;text-align: right;letter-spacing: 11px;'>平房:</span><span>" + data.Bungalow + "</span></div></div>");
                        "" == c.address || c.geometry || n.push("<div id='address' style='overflow: hidden;'><div style='width: 155px;float: left;'><span style='display: inline-block;width: 64px;text-align: right;letter-spacing: 11px;'>楼房:</span><span>" + data.Building + "</span></div><div style='width: 155px;float: right;'><span style='display: inline-block;width: 64px;text-align: right;letter-spacing: 5px;'>门牌号:</span><span>" + data.HouseNumber + "</span></div></div>");
                        "" == c.address || c.geometry || n.push("<div id='address' style='overflow: hidden;'><div style='width: 155px;float: left;'><span style='display: inline-block;width: 64px;text-align: right;'>政治面貌:</span><span>" + data.PoliticsName + "</span></div><div style='width: 155px;float: right;'><span style='display: inline-block;width: 64px;text-align: right;'>总人口数:</span><span>" + data.TotalPopulation + "</span></div></div>");
                        "" == c.address || c.geometry || n.push("<div id='address' style='overflow: hidden;'><div style='width: 155px;float: left;'><span style='display: inline-block;width: 64px;text-align: right;'>从事行业:</span><span>农民</span></div><div style='width: 155px;float: right;'><span style='display: inline-block;width: 64px;text-align: right;'>空巢老人:</span><span>是</span></div></div>");
                        "" == c.address || c.geometry || n.push("<div id='address' style='overflow: hidden;'><div style='width: 155px;float: left;'><span style='display: inline-block;width: 64px;text-align: right;'>家庭关系:</span><span>本人</span></div><div style='width: 155px;float: right;'><span style='display: inline-block;width: 64px;text-align: right;letter-spacing: 5px;'>五保户:</span><span>是</span></div></div>");
                        "" == c.address || c.geometry || n.push("<div id='address' style='overflow: hidden;'><div style='width: 155px;float: left;'><span style='display: inline-block;width: 64px;text-align: right;'>烈士军属:</span><span>是</span></div><div style='width: 155px;float: right;'><span style='display: inline-block;width: 64px;text-align: right;'>享受低保:</span><span>是</span></div></div>");
                        "" == c.address || c.geometry || n.push("<div id='address' style='overflow: hidden;'><div style='width: 155px;float: left;'><span style='display: inline-block;width: 64px;text-align: right;'>鳏寡孤独:</span><span>是</span></div><div style='display: none;width: 155px;float: right;'><span style='display: inline-block;width: 64px;text-align: right;'>姓名姓名:</span><span>自定义</span></div></div>");
                        "" == c.address || c.geometry || n.push("<div id='address' style='overflow: hidden;'><div style='width: 155px;float: left;'><span style='display: inline-block;width: 78px;text-align: right;'>承包田亩数:</span><span>0</span></div><div style='width: 155px;float: right;'><span style='display: inline-block;width: 78px;text-align: right;'>责任田亩数:</span><span>0</span></div></div>");
                        "" == c.address || c.geometry || n.push("<div id='address' style='overflow: hidden;'><div style='width: 360px;float: left;'><span style='display: inline-block;width: 64px;text-align: right;'>身份证号:</span><span>372925199806252555</span></div><div style='display: none;width: 155px;float: right;'><span style='display: inline-block;width: 64px;text-align: right;'>姓名姓名:</span><span>自定义</span></div></div>");
                        if (c.geometry && -1 < c.geometry.indexOf("LINESTRING")) {
                            e = c.lsid.split(",");
                            h = [];
                            for (var q = 0; q < e.length; q++) h.push("实体码%3D%27" + e[q] + "%27");
                            url = "http://124.128.48.217:6080/arcgis/rest/services/gjfx/MapServer/0/query?where=" + h.join("+or+") + "&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=穿越地市名%2C穿越地市数%2C穿越县区数%2C穿越县区名&returnGeometry=false&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=pjson"
                        }
                        $("#right_pointNameInfo").append(n.join(""));
                        $("#pointPopupContent").append('<div id="tabs"><ul><li id="tabs-li1"><a href="#tabs1" class=""><img src="../Content/Map/images/blank.gif">到这里去    </a></li><li id="tabs-li2"><a href="#tabs2"><img src="../Content/Map/images/blank.gif">从这里出发    </a></li><li id="tabs-li3"><a href="#tabs3" class="selected"><img src="../Content/Map/images/blank.gif">周边搜索    </a></li></ul><div id="tabs1" class="pointTabDiv" style="display: none;"><span style="margin-right:4px;">起点</span><input type="text" id="pointFromText"><input type="button" id="pointFromButton" class="btnSmall" style="margin:-5px 0 0 10px" value="驾车"></div><div id="tabs2" style="display: none;"><span style="margin-right:4px;">终点</span><input type="text" id="pointToText"><input type="button" id="pointToButton" class="btnSmall" style="margin:-5px 0 0 10px" value="驾车"></div><div id="tabs3" style="display: block;"><input type="button" class="pointPopupBtn" code="5080 5082:5085 5380 5501 5502 5400" value="宾馆"><input type="button" class="pointPopupBtn" code="A180:A192 A195:A19C" value="银行"><input type="button" class="pointPopupBtn" code="7200 7203:7206 7280 7281 7500" value="医院"><input type="text" id="pointSearch" style="width:80px"><select name="selectAge" id="selectRadius" style="height:23px;margin-left:2px;border: #b3b3b3 solid 1px;"><option value="500">500米</option><option value="800">800米</option><option value="1000">1000米</option><option value="2000">2000米</option><option value="5000">5000米</option></select><input type="button" value="搜索" id="pointPopupSearchBtn" class="btnSmall" style="margin:-5px 0 0 4px"></div></div>');
                        $("#poi_pop_info").css({
                            width: "333px"
                        });
                        $("#markName").text(c.name);

                        break;
                    case "fireFightingWork"://消防工作

                        f = new Ol2.Popup.FramedCloud("搜索", d, null, '<div id="poi_pop_info" style = "min-height:90px;width:333px;font-size:12px;"><div id = "mark_title"><div id="markName" style="padding-left:10px;font-size:14px;color:#3b9cfe;font-weight:700;margin-top:-2px;"></div></div><div id = "pointPopupContent" style = "margin-top:10px;display:block"><div id="right_pointNameInfo" style="margin-left: 10px;"></div></div></div>', null, !0, k);
                        b.map.addPopup(f);
                        n = [];

                        var data = c.fireFightingWorkViewModel;
                        var fileData = data.fileList;

                        var str = "<div id='phone' style='overflow: hidden;'>";
                        for (var i = 0; i < fileData.length; i++) {
                            str += "<div id='myalert' class='myalert' data-img='" + fileData[i].Url + "' style='float:left;width:86px;height:96px;margin:5px;' onclick='showImg(this)'><img id='myImg' alt='" + fileData[i].Title + "' style='width:100%;height:100%;' src='" + fileData[i].Url + "' /></div>";
                        }
                        str += "</div>";

                        "" == c.telephone || c.geometry || n.push(str);

                        "" == c.address || c.geometry || n.push("<div id='address'>地址:" + c.address + "</div>");
                        "" == c.content || c.geometry || n.push("<div id='phone'><div style='margin-bottom:5px;'>描述:</div><textarea style='resize: none;' id=\"TextArea1\" rows=\"7\" cols=\"45\">" + data.Desc + "</textarea></div>");
                        if (c.geometry && -1 < c.geometry.indexOf("LINESTRING")) {
                            e = c.lsid.split(",");
                            h = [];
                            for (var q = 0; q < e.length; q++) h.push("实体码%3D%27" + e[q] + "%27");
                            url = "http://124.128.48.217:6080/arcgis/rest/services/gjfx/MapServer/0/query?where=" + h.join("+or+") + "&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=穿越地市名%2C穿越地市数%2C穿越县区数%2C穿越县区名&returnGeometry=false&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=pjson"
                        }
                        $("#right_pointNameInfo").append(n.join(""));
                        $("#pointPopupContent").append('<div id="tabs"><ul><li id="tabs-li1"><a href="#tabs1" class=""><img src="../Content/Map/images/blank.gif">到这里去    </a></li><li id="tabs-li2"><a href="#tabs2"><img src="../Content/Map/images/blank.gif">从这里出发    </a></li><li id="tabs-li3"><a href="#tabs3" class="selected"><img src="../Content/Map/images/blank.gif">周边搜索    </a></li></ul><div id="tabs1" class="pointTabDiv" style="display: none;"><span style="margin-right:4px;">起点</span><input type="text" id="pointFromText"><input type="button" id="pointFromButton" class="btnSmall" style="margin:-5px 0 0 10px" value="驾车"></div><div id="tabs2" style="display: none;"><span style="margin-right:4px;">终点</span><input type="text" id="pointToText"><input type="button" id="pointToButton" class="btnSmall" style="margin:-5px 0 0 10px" value="驾车"></div><div id="tabs3" style="display: block;"><input type="button" class="pointPopupBtn" code="5080 5082:5085 5380 5501 5502 5400" value="宾馆"><input type="button" class="pointPopupBtn" code="A180:A192 A195:A19C" value="银行"><input type="button" class="pointPopupBtn" code="7200 7203:7206 7280 7281 7500" value="医院"><input type="text" id="pointSearch" style="width:80px"><select name="selectAge" id="selectRadius" style="height:23px;margin-left:2px;border: #b3b3b3 solid 1px;"><option value="500">500米</option><option value="800">800米</option><option value="1000">1000米</option><option value="2000">2000米</option><option value="5000">5000米</option></select><input type="button" value="搜索" id="pointPopupSearchBtn" class="btnSmall" style="margin:-5px 0 0 4px"></div></div>');
                        $("#poi_pop_info").css({
                            width: "333px"
                        });
                        $("#markName").text(c.name);

                        break;
                    case "police":
                        debugger;
                        f = new Ol2.Popup.FramedCloud("搜索", d, null, '<div id="poi_pop_info" style = "min-height:90px;width:333px;font-size:12px;"><div id = "mark_title"><div id="markName" style="padding-left:10px;font-size:14px;color:#3b9cfe;font-weight:700;margin-top:-2px;"></div></div><div id = "pointPopupContent" style = "margin-top:10px;display:block"><div id="right_pointNameInfo"></div></div></div>', null, !0, k);
                        b.map.addPopup(f);
                        n = [];
                        "" == c.address || c.geometry || n.push("<div id='address'>报警人:" + c.creatUserName + "</div>");
                        "" == c.telephone || c.geometry || n.push("<div id='phone'>报警时间:" + new Date(c.creationTime).toLocaleString() + "</div>");
                        "" == c.telephone || c.geometry || n.push("<div id='phone'>报警地址:" + c.address + "</div>");
                        //链接到后台处理
                        n.push("<div id='phone'><a href='../Application/Index#!/callPoliceAcceptance' target='_blank'>点击处置</a></div>");
                        //if (c.geometry && -1 < c.geometry.indexOf("LINESTRING")) {
                        //    e = c.lsid.split(",");
                        //    h = [];
                        //    for (var q = 0; q < e.length; q++) h.push("实体码%3D%27" + e[q] + "%27");
                        //    url = "http://124.128.48.217:6080/arcgis/rest/services/gjfx/MapServer/0/query?where=" + h.join("+or+") + "&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=穿越地市名%2C穿越地市数%2C穿越县区数%2C穿越县区名&returnGeometry=false&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=pjson"
                        //}
                        $("#right_pointNameInfo").append(n.join(""));
                        //$("#pointPopupContent").append('<div id="tabs"><ul><li id="tabs-li1"><a href="#tabs1" class=""><img src="../Content/Map/images/blank.gif">到这里去    </a></li><li id="tabs-li2"><a href="#tabs2"><img src="../Content/Map/images/blank.gif">从这里出发    </a></li><li id="tabs-li3"><a href="#tabs3" class="selected"><img src="../Content/Map/images/blank.gif">周边搜索    </a></li></ul><div id="tabs1" class="pointTabDiv" style="display: none;"><span style="margin-right:4px;">起点</span><input type="text" id="pointFromText"><input type="button" id="pointFromButton" class="btnSmall" style="margin:-5px 0 0 10px" value="驾车"></div><div id="tabs2" style="display: none;"><span style="margin-right:4px;">终点</span><input type="text" id="pointToText"><input type="button" id="pointToButton" class="btnSmall" style="margin:-5px 0 0 10px" value="驾车"></div><div id="tabs3" style="display: block;"><input type="button" class="pointPopupBtn" code="5080 5082:5085 5380 5501 5502 5400" value="宾馆"><input type="button" class="pointPopupBtn" code="A180:A192 A195:A19C" value="银行"><input type="button" class="pointPopupBtn" code="7200 7203:7206 7280 7281 7500" value="医院"><input type="text" id="pointSearch" style="width:80px"><select name="selectAge" id="selectRadius" style="height:23px;margin-left:2px;border: #b3b3b3 solid 1px;"><option value="500">500米</option><option value="800">800米</option><option value="1000">1000米</option><option value="2000">2000米</option><option value="5000">5000米</option></select><input type="button" value="搜索" id="pointPopupSearchBtn" class="btnSmall" style="margin:-5px 0 0 4px"></div></div>');
                        //$("#mark_title").append("<div id='poi_correct' title='纠错'></div>");
                        $("#poi_pop_info").css({
                            width: "333px"
                        });
                        $("#markName").text("报警详情");

                        break;
                    case "around":
                        f = new Ol2.Popup.FramedCloud("搜索", d, null, '<div id="poi_pop_info" style = "min-height:90px;width:333px;font-size:12px;"><div id = "mark_title"><div id="markName" style="padding-left:10px;font-size:14px;color:#3b9cfe;font-weight:700;margin-top:-2px;"></div></div><div id = "pointPopupContent" style = "margin-top:10px;display:block"><div id="right_pointNameInfo"></div></div></div>', null, !0, k);
                        f.autoSize = !0;
                        b.map.addPopup(f);
                        $("#poi_pop_info").css({
                            width: "333px",
                            height: "100px"
                        });
                        f.updateSize();
                        $("#pointPopupContent").append('<div id="tabs"><ul><li id = "tabs-li1"><a href="#tabs1" class="selected"><img src="../Content/Map/../Content/Map/images/blank.gif"/>到这里去    </a></li><li id = "tabs-li2"><a href="#tabs2" ><img src="../Content/Map/images/blank.gif"/>从这里出发    </a></li><li id = "tabs-li3"><a href="#tabs3" ><img src="../Content/Map/images/blank.gif"/>周边搜索    </a></li></ul><div id="tabs1" class = "pointTabDiv"><span style="margin-right:4px;">起点</span><input type="text" id="pointFromText"><input type="button" id="pointFromButton" class="btnSmall" style="margin:-5px 0 0 10px" value="驾车"></div><div id="tabs2"><span style="margin-right:4px;">终点</span><input type="text" id="pointToText"><input type ="button" id="pointToButton" class="btnSmall" style="margin:-5px 0 0 10px" value="驾车"></div><div id="tabs3"><input type = "button" class = "pointPopupBtn" code="5080 5082:5085 5380 5501 5502 5400" value ="宾馆"><input type = "button" class = "pointPopupBtn" code="A180:A192 A195:A19C" value ="银行"><input type = "button" class = "pointPopupBtn" code="7200 7203:7206 7280 7281 7500" value ="医院"><input type = "text" id = "pointSearch" style = "width:80px"><select name="selectAge" id="selectRadius" style="height:23px;margin-left:2px;border: #b3b3b3 solid 1px;"><option value="500">500米</option><option value="800">800米</option><option value="1000">1000米</option><option value="2000">2000米</option><option value="5000">5000米</option></select><input type ="button" value = "搜索" id = "pointPopupSearchBtn" class = "btnSmall"  style="margin:-5px 0 0 4px" ></div></div>');
                        WholeSearch.request("rgc2", {
                            point: d.lon + "," + d.lat,
                            type: 1
                        },
                            l);
                        $("#markName").text("未知地点");
                        break;
                    case "plotinfo":
                        f = new Ol2.Popup.FramedCloud("标注信息", d, null, '<div id="poi_pop_info" style = "min-height:90px;width:333px;font-size:12px;"><div id = "mark_title"><div id="markName" style="padding-left:10px;font-size:14px;color:#3b9cfe;font-weight:700;margin-top:-2px;"></div></div><div id = "pointPopupContent" style = "margin-top:10px;display:block"><div id="right_pointNameInfo"></div></div></div>', null, !0, k);
                        b.map.addPopup(f);
                        "point" == c.type && ($("#pointPopupContent").append('<div id="tabs"><ul><li id = "tabs-li1"><a href="#tabs1" class="selected"><img src="../Content/Map/images/blank.gif"/>到这里去    </a></li><li id = "tabs-li2"><a href="#tabs2" ><img src="../Content/Map/images/blank.gif"/>从这里出发    </a></li><li id = "tabs-li3"><a href="#tabs3" ><img src="../Content/Map/images/blank.gif"/>周边搜索    </a></li></ul><div id="tabs1" class = "pointTabDiv"><span style="margin-right:4px;">起点</span><input type="text" id="pointFromText"><input type="button" id="pointFromButton" class="btnSmall" style="margin:-5px 0 0 10px" value="驾车"></div><div id="tabs2"><span style="margin-right:4px;">终点</span><input type="text" id="pointToText"><input type ="button" id="pointToButton" class="btnSmall" style="margin:-5px 0 0 10px" value="驾车"></div><div id="tabs3"><input type = "button" class = "pointPopupBtn" code="5080 5082:5085 5380 5501 5502 5400" value ="宾馆"><input type = "button" class = "pointPopupBtn" code="A180:A192 A195:A19C" value ="银行"><input type = "button" class = "pointPopupBtn" code="7200 7203:7206 7280 7281 7500" value ="医院"><input type = "text" id = "pointSearch" style = "width:80px"><select name="selectAge" id="selectRadius" style="height:23px;margin-left:2px;border: #b3b3b3 solid 1px;"><option value="500">500米</option><option value="800">800米</option><option value="1000">1000米</option><option value="2000">2000米</option><option value="5000">5000米</option></select><input type ="button" value = "搜索" id = "pointPopupSearchBtn" class = "btnSmall"  style="margin:-5px 0 0 4px" ></div></div>'), $("#poi_pop_info").css({
                            width: "333px"
                        }));
                        break;
                    case "plotedit":
                        f = new Ol2.Popup.FramedCloud("标注信息", d, null, '<div id="poi_pop_info" style = "min-height:90px;width:333px;font-size:12px;"><div id = "mark_title"><div id="markName" style="padding-left:10px;font-size:14px;color:#3b9cfe;font-weight:700;margin-top:-2px;"></div></div><div id = "pointPopupContent" style = "margin-top:10px;display:block"><div id="right_pointNameInfo"></div></div></div>', null, !0, k);
                        f.autoSize = !0;
                        b.map.addPopup(f);
                        $("#poi_pop_info").css({
                            width: "313px"
                        });
                        break;
                    case "resourcelist":
                        f = new Ol2.Popup.FramedCloud("搜索", d, null, '<div id="poi_pop_info" style = "min-height:90px;width:333px;font-size:12px;"><div id = "mark_title"><div id="markName" style="padding-left:10px;font-size:14px;color:#3b9cfe;font-weight:700;margin-top:-2px;"></div></div><div id = "pointPopupContent" style = "margin-top:10px;display:block"><div id="right_pointNameInfo"></div></div></div>', null, !0, k);
                        var v = 50;
                        n = "<div class='resource_detail'>";
                        $.each(c,
                            function (a) {
                                "OBJECTID" != a.toUpperCase() && "NAME" != a.toUpperCase() && 0 > a.toUpperCase().indexOf("SHAPE") && (n += a + ":" + c[a] + "<br/>", v += 18 * Math.ceil(c[a].length / 15))
                            });
                        n += "</div>";
                        f.autoSize = !0;
                        b.map.addPopup(f);
                        $("#poi_pop_info").css("height", v + "px");
                        f.updateSize();
                        $("#right_pointNameInfo").append(n);
                        $("#markName").text(c.NAME || c.名称)
                }
                a = new Ol2.Feature.Vector(new Ol2.Geometry.Point(d.lon, d.lat), c);
                $("#tabs ul").idTabs();
                $("#tabs-li3 a").click();
                f.updateSize();
                m()
            },
            close: k,
            clear: function () {
                DragMoveCtl.clear()
            },
            resize: function () {
                f.updateSize();
                f.panIntoView()
            }
        }
    }(),
    ImgMetaCtl = function () {
        function l() {
            if (v) {
                var a = $(this),
                    b = a.attr("lid");
                y = b;
                $("#metalist :radio").removeAttr("checked");
                a.find(":radio")[0].checked = !0;
                n.tileLayerManager.setVisibility("img", !1);
                q && n.removeLayer(q);
                for (var e in stimgLayerCfg) if (stimgLayerCfg[e].lid == b) {
                    q = new Ol2.Layer.WMTS(stimgLayerCfg[e]);
                    n.addLayer(q);
                    n.map.setLayerIndex(q, 1);
                    break
                }
                g()
            }
        }
        function c(b) {
            if (v) if (q && n.removeLayer(q), q = null, "img" == b) {
                for (var e in stimgLayerCfg) if (0 == stimgLayerCfg[e].idx) {
                    y = stimgLayerCfg[e].lid;
                    break
                }
                isImg = !0;
                a();
                $("#stImgmetaInfo").show()
            } else $("#stImgmetaInfo").hide(),
                isImg = !1
        }
        function m(a) {
            a && 0 != a.length ? (u = a, u.sort(b), g()) : ($("#metainfo").text("当前图层范围无影像元数据信息！"), $("#metalist ul").empty(), u = [])
        }
        function g() {
            var a, b, e, c = h(u, y, "lid"); -1 == c && $("#metainfo").text("当前图层范围无影像元数据信息！");
            var p = [];
            t = [];
            for (a = 0; a < u.length; a++) {
                b = u[a];
                e = k(b.st);
                0 != b.et && (e += "-" + k(b.et));
                e += "," + b.reso + "米";
                var f = {};
                f.str = e;
                f.grp = b.lid;
                if (-1 != c && b.lid == u[c].lid) 0 < t.length && t[t.length - 1].str == f.str && t.splice(t.length - 1, 1),
                    f.isChoosed = !0,
                    e = "影像获取时间：" + k(b.st),
                    0 != b.et && (e += "~" + k(b.et)),
                    $("#metainfo").text(e + "," + b.reso + "米"),
                    p.push("<li lid='" + f.grp + "'><input type='radio' name='souce_radio' checked='checked' />" + f.str + "</li>");
                else {
                    if (0 < t.length && t[t.length - 1].str == f.str) continue;
                    p.push("<li lid='" + f.grp + "'><input type='radio' name='souce_radio'  />" + f.str + "</li>");
                    f.isChoosed = !1
                }
                t.push(f)
            }
            $("#metalist ul").empty().append(p.join(""));
            d || $("#meta_hand").show();
            r && ($("#meta_hand").hide(), $("#metalist").show(), r = !1, setTimeout(function () {
                $("#metalist").hide();
                $("#meta_hand").show()
            },
                3E3))
        }
        function h(a, b, e) {
            for (var d = 0; d < a.length; d++) if (a[d][e] == b) return d;
            return -1
        }
        function k(a) {
            var b = a.toString(),
                e;
            6 == b.length ? e = b.substr(0, 4) + "年" + a % 100 + "月" : 4 == b.length && (e = b + "年");
            return e
        }
        function b(a, b) {
            return a.st.toString() > b.st.toString() ? -1 : a.st.toString() < b.st.toString() ? 1 : 0
        }
        function a() {
            var a = n.map.getCenter();
            $.ajax({
                url: f + "wktpoint=" + ("POINT(" + a.lon + " " + a.lat + ")") + "&level=" + n.map.zoom,
                success: m,
                dataType: "jsonp"
            })
        }
        function e() {
            v && (!isImg || 9 > n.map.zoom || a())
        }
        var f = "",
            d = "",
            r = !0,
            t = [],
            n,
            w = !1,
            y,
            q,
            v = !0,
            u = [];
        return {
            init: function (a, b) {
                w || (f = a, n = b, n.map.events.on({
                    moveend: e,
                    scope: this
                }), $("#refrenceDiv").after("<div id='stImgmetaInfo'>    <div id='metalist'>        <div style='position: relative'><label>当前范围历史影像</label><img id='imgmeta_spin' width='15px' src='../Content/map/images/spin.png' style='right: 10px'/></div><hr/><ul></ul></div>   <div><img id='meta_hand' src='../Content/Map/images/clickr.gif' width='26px'/><span id='metainfo'></span></div> </div>"), $("#metalist").on("click", "li", null, l), $("#metainfo").mouseover(function () {
                    1 > t.length || ($("#meta_hand").hide(), $("#metalist").fadeIn(500))
                }), $("#stImgmetaInfo").mouseleave(function () {
                    d || ($("#metalist").fadeOut(500), $("#meta_hand").show())
                }), $("#imgmeta_spin").click(function () {
                    d ? ($(this).attr({
                        src: "../Content/map/images/spin.png",
                        width: "15px"
                    }), d = "") : ($(this).attr({
                        src: "../Content/map/images/spin1.png",
                        width: "9px"
                    }), d = "1")
                }), n.tileLayerManager.addListener(c), w = !0)
            },
            setActive: function (a) {
                v = !!a
            }
        }
    }(),
    Plotting = function () {
        function l() {
            var a = ["<div id='pointmark_imgdiv'><ul id='ulPoint'>"],
                b;
            for (b = 0; b < G.length; b++) a.push("<li><img src='../Content/map/images/mark2/" + G[b] + ".png' class='sp_12'></li>");
            a.push("</ul><div id='pointImgRtn' class='toolbtn' style='position:relative;margin:auto;display:block;'  >返回</div>");
            return a.join("")
        }
        function c(a) {
            z.removeAllFeatures();
            var b = [];
            H = [];
            if (a.d && 0 < a.d.length) {
                for (var e = new Ol2.Bounds,
                    p = 0; p < a.d.length; p++) {
                    var d = a.d[p];
                    b.push('<li id="' + d.ID + '"><input type="checkbox"><img src="../Content/map/images/mark2/plot_' + d.STYLE.type + '.png"> ' + d.TITLE + "</li>");
                    var f = null,
                        c = Ol2.Util.extend({},
                            Ol2.Feature.Vector.style["default"]),
                        n = d.GEOMETRY.isWKT,
                        q = new Ol2.Format.WKT;
                    "point" == d.STYLE.type && (f = n ? q.read(d.GEOMETRY.WKT) : new Ol2.Feature.Vector(new Ol2.Geometry.Point(d.GEOMETRY.GEOMETRY[0].x, d.GEOMETRY.GEOMETRY[0].y)), c.graphicWidth = d.STYLE.width, c.graphicHeight = d.STYLE.height, c.externalGraphic = d.STYLE.image);
                    if ("polyline" == d.STYLE.type) {
                        if (n) f = q.read(d.GEOMETRY.WKT);
                        else {
                            for (var f = [], v = 0; v < d.GEOMETRY.GEOMETRY.length; v++) {
                                var h = new Ol2.Geometry.Point(d.GEOMETRY.GEOMETRY[v].x, d.GEOMETRY.GEOMETRY[v].y);
                                f.push(h)
                            }
                            f = new Ol2.Feature.Vector(new Ol2.Geometry.LineString(f))
                        }
                        c.strokeWidth = d.STYLE.weight;
                        c.strokeColor = d.STYLE.color;
                        c.strokeDashstyle = d.STYLE.style ? d.STYLE.style : d.STYLE.dashstyle;
                        c.strokeOpacity = d.STYLE.alpha ? d.STYLE.alpha : d.STYLE.opacity
                    }
                    if ("polygon" == d.STYLE.type) {
                        if (n) f = q.read(d.GEOMETRY.WKT);
                        else {
                            f = [];
                            for (v = 0; v < d.GEOMETRY.GEOMETRY.length; v++) h = new Ol2.Geometry.Point(d.GEOMETRY.GEOMETRY[v].x, d.GEOMETRY.GEOMETRY[v].y),
                                f.push(h);
                            f = new Ol2.Geometry.LinearRing(f);
                            f = new Ol2.Feature.Vector(new Ol2.Geometry.Polygon(f))
                        }
                        c.strokeWidth = d.STYLE.weight;
                        c.strokeColor = d.STYLE.color;
                        c.strokeDashstyle = d.STYLE.style ? d.STYLE.style : d.STYLE.dashstyle;
                        c.strokeOpacity = d.STYLE.alpha ? d.STYLE.alpha : d.STYLE.opacity;
                        c.fillColor = d.STYLE.fillColor;
                        c.fillOpacity = d.STYLE.fillAlpha ? d.STYLE.fillAlpha : d.STYLE.fillOpacity
                    }
                    "label" == d.STYLE.type && (f = n ? q.read(d.GEOMETRY.WKT) : new Ol2.Feature.Vector(new Ol2.Geometry.Point(d.GEOMETRY.GEOMETRY[0].x, d.GEOMETRY.GEOMETRY[0].y)), c.label = d.TITLE, c.labelAlign = d.STYLE.placement, c.fontColor = d.STYLE.fontColor, c.labelXOffset = d.STYLE.xoffset, c.labelYOffset = d.STYLE.yoffset, c.fontFamily = d.STYLE.fontFamily, c.fontSize = d.STYLE.fontSize, d.STYLE.border && (c.labelOutlineColor = d.STYLE.borderColor), d.STYLE.italic && (c.fontStyle = "italic"), d.STYLE.bold && (c.fontWeight = "bold"));
                    f.style = c;
                    f.attributes = {
                        id: d.ID,
                        remark: d.MEMO,
                        type: "polyline" == d.STYLE.type ? "line" : "label" == d.STYLE.type ? "text" : d.STYLE.type,
                        name: d.TITLE
                    };
                    d = f;
                    e.extend(d.geometry.getBounds());
                    H.push(d)
                }
                z.addFeatures(H);
                C.map.zoomToExtent(e)
            }
            $("#mark_result").show();
            $("#mark_result #mark_count").text(H.length);
            $("#mark_quryList").empty().append(b.join(""))
        }
        function m(a) {
            var b = [],
                d;
            if (a.CLASS_NAME.match(/(LineString)$/)) for (a = p.geometry.components, d = 0; d < a.length; d++) b.push([a[d].x, a[d].y]);
            else if (a.CLASS_NAME.match(/(Polygon)$/)) for (a = p.geometry.components[0].components, d = 0; d < a.length; d++) b.push([a[d].x, a[d].y]);
            else b.push([a.x, a.y]);
            return b.join(",")
        }
        function g(a, b) {
            if (null != b) return "middle" == a ? "cm" : "bottom" == a ? "cb" : "top" == a ? "ct" : "cm";
            if (!a) return "middle";
            var d = a.substr(a.length - 1, 1);
            return "b" == d ? "bottom" : "m" == d ? "middle" : "t" == d ? "top" : "middle"
        }
        function h() {
            if (g_userid && "0" != g_userid) {
                var a, b = p.style,
                    d = p.attributes;
                switch (d.type) {
                    case "point":
                        a = d.id ? {
                            ID: d.id,
                            TITLE: d.name,
                            OP: "UpdateUserPlot",
                            STYLE: JSON.stringify({
                                type: "point",
                                width: b.graphicWidth,
                                height: b.graphicHeight,
                                image: b.externalGraphic
                            }),
                            GEOMETRY: p.geometry.x + "," + p.geometry.y,
                            MEMO: d.remark,
                            USERID: g_userid
                        } : {
                                TITLE: p.attributes.name,
                                OP: "AddUserPlot",
                                STYLE: JSON.stringify({
                                    type: "point",
                                    width: b.graphicWidth,
                                    height: b.graphicHeight,
                                    image: b.externalGraphic
                                }),
                                GEOMETRY: p.geometry.x + "," + p.geometry.y,
                                MEMO: d.remark,
                                USERID: g_userid
                            };
                        break;
                    case "line":
                        a = d.id ? {
                            ID: d.id,
                            TITLE: d.name,
                            OP: "UpdateUserPlot",
                            STYLE: JSON.stringify({
                                type: "polyline",
                                alpha: b.strokeOpacity,
                                color: b.strokeColor,
                                weight: b.strokeWidth,
                                style: b.strokeDashstyle
                            }),
                            GEOMETRY: m(p.geometry),
                            MEMO: d.remark,
                            USERID: g_userid
                        } : {
                                TITLE: d.name,
                                OP: "AddUserPlot",
                                STYLE: JSON.stringify({
                                    type: "polyline",
                                    alpha: b.strokeOpacity,
                                    color: b.strokeColor,
                                    weight: b.strokeWidth,
                                    style: b.strokeDashstyle
                                }),
                                GEOMETRY: m(p.geometry),
                                MEMO: d.remark,
                                USERID: g_userid
                            };
                        break;
                    case "polygon":
                        a = d.id ? {
                            ID: d.id,
                            TITLE: d.name,
                            OP: "UpdateUserPlot",
                            STYLE: JSON.stringify({
                                type: "polygon",
                                alpha: b.strokeOpacity,
                                color: b.strokeColor,
                                weight: b.strokeWidth,
                                style: b.strokeDashstyle,
                                fillColor: b.fillColor,
                                fillAlpha: b.fillOpacity
                            }),
                            GEOMETRY: m(p.geometry),
                            MEMO: d.remark,
                            USERID: g_userid
                        } : {
                                TITLE: d.name,
                                OP: "AddUserPlot",
                                STYLE: JSON.stringify({
                                    type: "polygon",
                                    alpha: b.strokeOpacity,
                                    color: b.strokeColor,
                                    weight: b.strokeWidth,
                                    style: b.strokeDashstyle,
                                    fillColor: b.fillColor,
                                    fillAlpha: b.fillOpacity
                                }),
                                GEOMETRY: m(p.geometry),
                                MEMO: d.remark,
                                USERID: g_userid
                            };
                        break;
                    case "text":
                        a = d.id ? {
                            ID: d.id,
                            TITLE: d.name,
                            OP: "UpdateUserPlot",
                            STYLE: JSON.stringify({
                                type: "label",
                                fontFamily: b.fontFamily,
                                fontSize: b.fontSize,
                                fontColor: b.fontColor,
                                xoffset: b.labelXOffset,
                                yoffset: b.labelYOffset,
                                bold: b.fontWeight,
                                italic: b.fontStyle,
                                color: b.strokeColor,
                                borderColor: b.labelOutlineColor,
                                placement: g(b.labelAlign),
                                border: !0
                            }),
                            GEOMETRY: m(p.geometry),
                            MEMO: d.remark,
                            USERID: g_userid
                        } : {
                                TITLE: d.name,
                                OP: "AddUserPlot",
                                STYLE: JSON.stringify({
                                    type: "label",
                                    fontFamily: b.fontFamily,
                                    fontSize: b.fontSize,
                                    fontColor: b.fontColor,
                                    xoffset: b.labelXOffset,
                                    yoffset: b.labelYOffset,
                                    bold: b.fontWeight,
                                    italic: b.fontStyle,
                                    color: b.strokeColor,
                                    borderColor: b.labelOutlineColor,
                                    placement: g(b.labelAlign),
                                    border: !0
                                }),
                                GEOMETRY: m(p.geometry),
                                MEMO: d.remark,
                                USERID: g_userid
                            }
                }
                $.ajax({
                    type: "POST",
                    url: Service.UserPlot,
                    data: a,
                    success: function (a, b) {
                        "" == a || null == a ? alert("保存失败！请重新保存") : (p.attributes.id || (p.attributes.id = a), alert("保存成功"))
                    },
                    error: function (a, b, d) {
                        alert(b)
                    }
                })
            } else alert("亲，用户登陆后才能够保存哦！请登陆后再试试！")
        }
        function k() {
            confirm("删除后不可恢复，确定要删除吗？") && (p.attributes.id && $.ajax({
                type: "POST",
                url: Service.UserPlot,
                data: {
                    OP: "DeleteUserPlot",
                    ID: p.attributes.id
                },
                success: function (a, b) {
                    "" == a || null == a ? alert("删除失败！") : alert("删除成功")
                },
                error: function (a, b, d) {
                    alert(b)
                }
            }), z.removeFeatures([p]), "none" != $("#mark_List").css("display") ? (H = z.features, $("#mark_quryList li[id='" + p.attributes.id + "']").remove()) : D = z.features, PoiInfoPop.close())
        }
        function b(b) {
            p = b.feature;
            B = Ol2.Util.extend({},
                p.style);
            b = p.attributes;
            var d = "";
            "line" == b.type ? (PoiInfoPop.show("plotinfo", p.geometry.components[p.geometry.components.length - 1], {
                type: "line"
            }), $("#markName").text("线标绘"), d = p.geometry.getGeodesicLength(C.map.getProjectionObject()), d = 1E3 < d ? "长度：" + (d / 1E3).toFixed(3) + "公里" : "长度：" + d.toFixed(3) + "米") : "polygon" == b.type ? (PoiInfoPop.show("plotinfo", p.geometry.getCentroid(), {
                type: "polygon"
            }), $("#markName").text("面标绘"), d = p.geometry.getGeodesicArea(C.map.getProjectionObject()), d = 1E5 < d ? "面积：" + (d / 1E6).toFixed(3) + "平方公里" : "面积：" + d.toFixed(3) + "平方米") : "text" == b.type ? (PoiInfoPop.show("plotinfo", p.geometry, {
                type: "text"
            }), $("#markName").text("文字标绘")) : (PoiInfoPop.show("plotinfo", p.geometry, {
                type: "point"
            }), $("#markName").text("点标绘"));
            $("#mark_title").append("<input type='button' id='popEditBtn' class='popEditBtn' title='修改' style='margin-right:20px'><input type='button'class='popEditBtn' id='popDelBtn'  title='删除'>");
            $("#right_pointNameInfo").html("<div>名称：" + p.attributes.name + "</div><div style='max-width:260px'>备注：" + (p.attributes.remark || "无") + "</div><div>" + d + "</div>");
            PoiInfoPop.resize();
            a()
        }
        function a() {
            $("#popEditBtn").click(function () {
                var a = p.attributes.type;
                "line" == a ? (PoiInfoPop.show("plotedit", p.geometry.components[p.geometry.components.length - 1], "line"), r()) : "polygon" == a ? (PoiInfoPop.show("plotedit", p.geometry.getCentroid(), "polygon"), n()) : "text" == a ? (PoiInfoPop.show("plotedit", p.geometry, "text"), y()) : (PoiInfoPop.show("plotedit", p.geometry, "point"), f())
            });
            $("#popDelBtn").click(function () {
                PoiInfoPop.close();
                k()
            })
        }
        function e(a) {
            $("#mark_tool_div .active").removeClass("active");
            var b = a.geometry;
            B.externalGraphic = "../Content/map/images/mark2/point7.png";
            B.graphicWidth = 24;
            B.graphicHeight = 24;
            B.graphicYOffset = -22;
            B.fillOpacity = 1;
            B.cursor = "pointer";
            a.style = Ol2.Util.extend({},
                B);
            a.style.label = "";
            a.attributes.type = "point";
            p = a;
            D.push(p);
            z.drawFeature(p);
            v[u].deactivate();
            PoiInfoPop.show("plotedit", b);
            f()
        }
        function f() {
            $("#poi_pop_info").css("height", "180px");
            $("#pointPopupContent").append(E);
            $("#pointmark_name").val(p.attributes.name || "").after("<div id='changeImg' style='cursor:pointer;position: absolute;top: 35px;right: 5px;text-decoration: underline;'><img id='pointImg' style='width:20px;'src='" + B.externalGraphic + "'/><br/>更换</div>");
            $("#pointmark_desc").text(p.attributes.remark || "");
            $("#pointPopupContent").after(l());
            $("#markName").text("点标绘");
            PoiInfoPop.resize();
            $("#changeImg").click(function () {
                $("#pointPopupContent").hide();
                $("#pointmark_imgdiv").show()
            });
            $("#pointmark_imgdiv .sp_12").click(function () {
                var a = $(this).attr("src");
                $("#pointImg").attr("src", a);
                p.style.externalGraphic = a;
                z.drawFeature(p);
                $("#pointImgRtn").click()
            });
            $("#pointImgRtn").click(function () {
                $("#pointPopupContent").show();
                $("#pointmark_imgdiv").hide()
            });
            $("#pointmark_save").click(function () {
                p.attributes.name = $("#pointmark_name").val();
                p.attributes.remark = $("#pointmark_desc").val();
                b({
                    feature: p
                });
                h()
            });
            $("#pointmark_delete").click(function () {
                PoiInfoPop.close();
                k()
            })
        }
        function d(a) {
            $("#mark_tool_div .active").removeClass("active");
            B.strokeWidth = 2;
            B.strokeOpacity = 1;
            B.strokeColor = "#0000ff";
            B.label = "";
            B.cursor = "pointer";
            a.style = Ol2.Util.extend({},
                B);
            a.style.label = "";
            a.attributes.type = "line";
            p = a;
            D.push(p);
            z.drawFeature(p);
            v[u].deactivate();
            PoiInfoPop.show("plotedit", p.geometry.components[a.geometry.components.length - 1]);
            r()
        }
        function r() {
            $("#poi_pop_info").css("height", "240px");
            $("#pointPopupContent").append(E);
            $("#pointmark_name").val(p.attributes.name || "");
            $("#pointmark_desc").text(p.attributes.remark || "");
            $("#markName").text("线标绘");
            $("#style_panel").append(I);
            q();
            $("#style_panel .ltrans").val(p.style.strokeOpacity);
            $.jPicker.List[0].color.active.val("hex", p.style.strokeColor.replace("#", ""), this);
            $("#style_panel .lwidth").val(p.style.strokeWidth);
            $("#style_panel .dropdown").attr("val", p.style.strokeDashstyle);
            $("#style_panel .dropdown p img").attr("src", $("#style_panel .dropdown img[val='" + p.style.strokeDashstyle + "']").attr("src"));
            PoiInfoPop.resize();
            $("#pointmark_save").click(function () {
                p.attributes.name = $("#pointmark_name").val();
                p.attributes.remark = $("#pointmark_desc").val();
                p.style.strokeOpacity = $("#style_panel .ltrans").val();
                p.style.strokeColor = "#" + $.jPicker.List[0].color.active.val("hex");
                p.style.strokeWidth = $("#style_panel .lwidth").val();
                p.style.strokeDashstyle = $("#style_panel .dropdown").attr("val");
                z.drawFeature(p);
                b({
                    feature: p
                });
                h()
            });
            $("#pointmark_delete").click(function () {
                PoiInfoPop.close();
                k()
            })
        }
        function t(a) {
            B.pointRadius = 24;
            B.fillColor = "#0000ff";
            B.fillOpacity = .5;
            B.strokeWidth = 2;
            B.strokeOpacity = 1;
            B.strokeColor = "#0000ff";
            B.cursor = "pointer";
            a.style = Ol2.Util.extend({},
                B);
            a.style.label = "";
            a.attributes.type = "polygon";
            p = a;
            D.push(p);
            z.drawFeature(p);
            PoiInfoPop.show("plotedit", p.geometry.getCentroid());
            v[u].deactivate();
            n()
        }
        function n() {
            $("#poi_pop_info").css("height", "270px");
            $("#pointPopupContent").append(E);
            $("#pointmark_name").val(p.attributes.name || "");
            $("#pointmark_desc").text(p.attributes.remark || "");
            $("#markName").text("面标绘");
            $("#style_panel").append(J);
            q();
            $("#style_panel .ltrans").val(p.style.strokeOpacity);
            $.jPicker.List[0].color.active.val("hex", p.style.strokeColor.replace("#", ""));
            $("#style_panel .lwidth").val(p.style.strokeWidth);
            $("#style_panel .dropdown").attr("val", p.style.strokeDashstyle);
            $("#style_panel .dropdown p img").attr("src", $("#style_panel .dropdown img[val='" + p.style.strokeDashstyle + "']").attr("src"));
            $.jPicker.List[1].color.active.val("hex", p.style.fillColor.replace("#", ""));
            $("#style_panel .ftrans").val(p.style.fillOpacity);
            PoiInfoPop.resize();
            $("#pointmark_save").click(function () {
                p.attributes.name = $("#pointmark_name").val();
                p.attributes.remark = $("#pointmark_desc").val();
                p.style.strokeOpacity = $("#style_panel .ltrans").val();
                p.style.strokeColor = "#" + $.jPicker.List[0].color.active.val("hex");
                p.style.strokeWidth = $("#style_panel .lwidth").val();
                p.style.strokeDashstyle = "#" + $("#style_panel .dropdown").attr("val");
                p.style.fillColor = "#" + $.jPicker.List[1].color.active.val("hex");
                p.style.fillOpacity = $("#style_panel .ftrans").val();
                z.drawFeature(p);
                b({
                    feature: p
                });
                h()
            });
            $("#pointmark_delete").click(function () {
                PoiInfoPop.close();
                k()
            })
        }
        function w(a) {
            $("#mark_tool_div .active").removeClass("active");
            B.pointRadius = 8;
            B.fillOpacity = 0;
            B.strokeOpacity = 0;
            B.fontColor = "#0000ff";
            B.fontSize = "12px";
            B.cursor = "pointer";
            B.labelOutlineColor = "#ffffff";
            B.labelSelect = !0;
            B.fontWeight = "bold";
            a.style = Ol2.Util.extend({},
                B);
            a.style.label = "";
            a.attributes.type = "text";
            p = a;
            D.push(p);
            z.drawFeature(p);
            PoiInfoPop.show("plotedit", p.geometry);
            v[u].deactivate();
            y()
        }
        function y() {
            $("#poi_pop_info").css("height", "290px");
            $("#pointPopupContent").append(E);
            $("#pointmark_name").val(p.attributes.name || "");
            $("#pointmark_desc").text(p.attributes.remark || "");
            $("#markName").text("文字标绘");
            $("#style_panel").append(A);
            q();
            $("#style_panel .tpos").val(g(p.style.labelAlign));
            $("#style_panel .xoff").val(p.style.labelXOffset || 0);
            $("#style_panel .yoff").val(p.style.labelYOffset || 0);
            p.style.labelOutlineColor ? ($.jPicker.List[1].color.active.val("hex", p.style.labelOutlineColor.replace("#", "")), $("#style_panel .tbord")[0].checked = !0) : ($("#style_panel .tbord")[0].checked = !1, $("#style_panel .lcolor").hide());
            $("#style_panel .txie")[0].checked = "italic" == p.style.fontStyle ? !0 : !1;
            $("#style_panel .tchu")[0].checked = "bold" == p.style.fontWeight ? !0 : !1;
            $.jPicker.List[0].color.active.val("hex", p.style.fontColor.replace("#", ""));
            $("#style_panel .tcolor").val(p.style.fontColor);
            $("#style_panel .tsize").val(parseInt(p.style.fontSize));
            $("#style_panel .tfam").val(p.style.fontFamily || "宋体");
            PoiInfoPop.resize();
            $("#pointmark_save").click(function () {
                p.attributes.name = $("#pointmark_name").val();
                p.attributes.remark = $("#pointmark_desc").val();
                p.style.label = p.attributes.name;
                p.style.labelAlign = g($("#style_panel .tpos").val(), "r");
                p.style.labelXOffset = $("#style_panel .xoff").val();
                p.style.labelYOffset = $("#style_panel .yoff").val();
                $("#style_panel .tbord")[0].checked && (p.style.labelOutlineColor = "#" + $.jPicker.List[1].color.active.val("hex"));
                p.style.fontStyle = $("#style_panel .txie")[0].checked ? "italic" : "nomal";
                p.style.fontWeight = $("#style_panel .tchu")[0].checked ? "bold" : "nomal";
                p.style.fontColor = "#" + $.jPicker.List[0].color.active.val("hex");
                p.style.fontSize = $("#style_panel .tsize").val() + "px";
                p.style.fontFamily = $("#style_panel .tfam").val();
                z.drawFeature(p);
                b({
                    feature: p
                });
                h()
            });
            $("#pointmark_delete").click(function () {
                PoiInfoPop.close();
                k()
            })
        }
        function q() {
            if (0 < $.jPicker.List.length) for (var a = $.jPicker.List.length - 1; -1 < a; a--) $.jPicker.List[a].destroy();
            $(".colorBtn").jPicker({
                window: {
                    expandable: !0,
                    position: {
                        x: "screenCenter",
                        y: "center"
                    }
                }
            },
                function (a, b) { },
                function (a, b) { },
                function (a, b) { });
            $("#poi_pop_info").parent().after($(".dropdown").remove());
            $(".spinner.wh").spinner({
                step: 1,
                min: 0,
                max: 10,
                numberFormat: "n"
            });
            $(".spinner.trans").spinner({
                step: .05,
                min: 0,
                max: 1,
                numberFormat: "n"
            });
            $(".spinner.unlimit").spinner({
                step: 1,
                numberFormat: "n"
            });
            $(".dropdown p").click(function () {
                var a = $(this).siblings("ul");
                "none" == a.css("display") ? a.slideDown("fast") : a.slideUp("fast")
            });
            $(".dropdown").mouseleave(function () {
                $(this).children("ul").hide()
            });
            $(".dropdown ul li img").click(function () {
                var a = $(this),
                    b = a.attr("src"),
                    d = a.parents(".dropdown");
                d.attr("val", a.attr("val"));
                d.find("p img").attr("src", b);
                d.children("ul").hide()
            })
        }
        var v = [],
            u = 0,
            z,
            F = !1,
            B,
            C,
            p,
            E,
            G,
            I,
            A,
            J,
            D = [],
            H = [];
        return {
            init: function (a, p) {
                if (!F) {
                    I = "<div class='stylediv line' style='position: relative;'>       <div>线颜色:<span class='colorBtn'/></div>       <div>线样式:<div  style='position:relative;width:60px;height:24px;display:inline-block;'>           <div class='dropdown' val='solid'>               <p ><img src='../Content/map/images/linestyle/solid.png'></p>               <ul>                   <li ><img val='solid' src='../Content/map/images/linestyle/solid.png'></li>                   <li ><img val='dash' src='../Content/map/images/linestyle/dash.png'></li>                   <li ><img val='dot' src='../Content/map/images/linestyle/dot.png'></li>                   <li ><img val='dashdot' src='../Content/map/images/linestyle/dashdot.png'></li>                   <li ><img val='longdashdot' src='../Content/map/images/linestyle/longdashdot.png'></li>               </ul>           </div>       </div>   </div>   <div>线宽:<input class='spinner wh lwidth'  value='2' /></div><div>透明度:<input class='spinner trans ltrans' value='1' /></div></div>";
                    A = " <div  class='stylediv text' style='position: relative;'>       <div>文字位置:<select class='tpos'><option>middle</option><option>top</option><option>bottom</option></select></div>       <div>文字颜色:<span class='colorBtn'/></div>       <div>x轴偏移:<input class='spinner unlimit xoff'  value='0' /></div>       <div>y轴偏移:<input class='spinner unlimit yoff'  value='0' /></div>       <div>字体:<select style='max-width:100px' class='tfam'>           <option>宋体</option>           <option>微软雅黑</option>           <option>楷体</option>           <option>仿宋</option>           <option>Algerian</option>           <option>Arial</option>           <option>Broadway</option>           <option>ComicSansMS</option>           <option>Courier</option>           <option>Verdana</option>           <option>TimesNewRoman</option>       </select>   </div>   <div>大小:<select class='tsize'>       <option>8</option>       <option>10</option>       <option>12</option>       <option>14</option>       <option>16</option>       <option>18</option>       <option>20</option>   </select></div>   <div><input class='tbord' type='checkbox'/>使用边框       <span class='colorBtn'/></div>       <div><input class='txie' type='checkbox'/>斜体</div>       <div><input class='tchu' type='checkbox'/>加粗</div>   </div>";
                    J = "<div class='stylediv polygon' style='position: relative'>           <div>线颜色:<span class='colorBtn'/></div><div>线样式:<div style='position:relative;width:60px;height:24px;display:inline-block;'>           <div class='dropdown' val='solid'>               <p><img src='../Content/map/images/linestyle/solid.png'></p>               <ul>                   <li ><img val='solid' src='../Content/map/images/linestyle/solid.png'></li>                   <li ><img val='dash' src='../Content/map/images/linestyle/dash.png'></li>                   <li ><img val='dot' src='../Content/map/images/linestyle/dot.png'></li>                   <li ><img val='dashdot' src='../Content/map/images/linestyle/dashdot.png'></li>                   <li ><img val='longdashdot' src='../Content/map/images/linestyle/longdashdot.png'></li>               </ul>           </div>       </div>   </div>   <div>线宽:<input class='spinner wh lwidth'  value='2' /></div><div>透明度:<input class='spinner trans ltrans' value='1' /></div>   <div>填充颜色:<span class='colorBtn'/></div><div>填充透明度:<input class='spinner trans ftrans'  value='1' /></div></div>";
                    E = "<div><span>名称:</span><input type='text' style='width:245px' id='pointmark_name'></div><div style='margin-top:10px;'><span style='float:left;'>备注:</span><textarea id='pointmark_desc'></textarea></div><div id='style_panel'></div><div style='height:25px;margin-top:10px;margin-left:80px;width:280px;' id='popup1BtnDiv'><div id='pointmark_save'>保  存</div><div id='pointmark_delete' style='margin-left:10px;'>删  除</div></div>";
                    G = "point0 point1 point2 point3 point4 point5 point6 point7 point8 point9 point10 point11 point12 point13 point14 point15 point16 point17 point18 point19 point20".split(" ");
                    "object" == typeof a ? $(a).append("<li class='toolbagClass' id='btnMarkDiv'><span class='btnToolbar-cont1'><span class='btnToolbar-img' style='background-position: -40px 0;top:4px;width:20px;'></span>标绘</span></li>") : $("#" + a).append("<li class='toolbagClass' id='btnMarkDiv'><span class='btnToolbar-cont1'><span class='btnToolbar-img' style='background-position: -40px 0;top:4px;width:20px;'></span>标绘</span></li>");
                    C = p;
                    $(C.map.div).after("<div id = 'mark_tool_div'title='地图标绘' onselectstart='return false' style='-moz-user-select:none;display:none'>\t<div class='marktool'><ul>\t\t<li class = 'markClas' style = 'background:url(../Content/map/images/ToolBar/tool_markpointer.png) no-repeat center'></li>\t\t<li class = 'markClas' title='单击确定点,双击结束绘制' style = 'background:url(../Content/map/images/ToolBar/tool_markline.png) no-repeat center'></li>\t\t<li class = 'markClas' title='单击确定点,双击结束绘制' style = 'background:url(../Content/map/images/ToolBar/tool_markpolygon.png) no-repeat center'></li>       <li class = 'markClas' style = 'background:url(../Content/map/images/ToolBar/tool_marktext.png) no-repeat center'></li>\t</ul></div>\t<div class='marklist' style='display:none;' ><div style=\"padding: 5px 5px 10px 5px;border-bottom: 1px dotted blue;margin-bottom: 8px;\"><input style=\"width:100px;\"  id=\"mark_qurytitle\"> <input type=\"button\" class=\"markBtn\" style=\"width:45px\" value=\"查询\" id=\"mark_qurybtn\"> <input type=\"button\" style=\"width: 55px;color:gray\" class=\"markBtn\" value=\"下载shp\" id=\"mark_download\"></div><div id='mark_result'style='display:none'><input id='mark_selectall' style='vertical-align:middle;margin: 0 4px;' type='checkbox'>查询结果 (共<span id='mark_count'>10</span>条)<input type='button' style='width: 65px;height:21px;margin-left:60px' class='markBtn' value='清除结果'id='mark_quryclear'/><ul id='mark_quryList' ></ul></div></div></div>");
                    $("#mark_tool_div").dialog({
                        autoOpen: !1,
                        resizable: !1,
                        position: [.5 * $(window).width() + 85, 32],
                        width: "auto",
                        maxHeight: "300px",
                        minHeight: "inherit",
                        minWidth: "inherit"
                    });
                    $("#mark_tool_div").css("min-height", "inherit");
                    $(".ui-dialog").css({
                        "z-index": "1000",
                        width: "auto",
                        "font-size": "12px",
                        border: "1px solid #25abf3"
                    });
                    $(".ui-dialog-title").after('<span style="position: absolute;right: 0;"><img id="mark_close" src="../Content/Map/images/blank.gif" title="关闭"><img id="mark_List" src="../Content/Map/images/blank.gif" title="标绘记录"><img id="mark_spin" src="../Content/map/images/blank.gif" title="标绘"></span>');
                    $(".ui-dialog .ui-dialog-titlebar ").css({
                        color: "#4d4d4d",
                        "font-weight": "700",
                        padding: "0 2px",
                        "font-size": "14px",
                        background: "url(../Scripts/map/Openlayers/theme/default/img/cloud-popup-relative.png) no-repeat -2px -1px",
                        border: "none"
                    });
                    $(".ui-dialog-titlebar-close ").hide();
                    var f = new Ol2.StyleMap({
                        "default": {
                            pointRadius: 24,
                            fillOpacity: 1,
                            graphicWidth: 24,
                            graphicHeight: 24,
                            graphicYOffset: -22,
                            externalGraphic: "../Content/map/images/mark2/point7.png",
                            graphicZIndex: 100,
                            fillColor: "blue",
                            strokeWidth: 2,
                            strokeOpacity: 1,
                            strokeColor: "red",
                            fontColor: "blue",
                            cursor: "pointer"
                        }
                    });
                    B = Ol2.Util.extend({},
                        Ol2.Feature.Vector.style["default"]);
                    z = new Ol2.Layer.Vector("plotLayer", {
                        style: f
                    });
                    C.addLayer(z, !0);
                    v = [new Ol2.Control.DrawFeature(z, Ol2.Handler.Point, {
                        handlerOptions: {
                            layerOptions: {
                                renderers: void 0,
                                styleMap: f
                            }
                        },
                        featureAdded: e
                    }), new Ol2.Control.DrawFeature(z, Ol2.Handler.Path, {
                        handlerOptions: {
                            layerOptions: {
                                renderers: void 0,
                                styleMap: f
                            }
                        },
                        featureAdded: d
                    }), new Ol2.Control.DrawFeature(z, Ol2.Handler.Polygon, {
                        handlerOptions: {
                            layerOptions: {
                                renderers: void 0,
                                styleMap: f
                            }
                        },
                        featureAdded: t
                    }), new Ol2.Control.DrawFeature(z, Ol2.Handler.Point, {
                        handlerOptions: {
                            layerOptions: {
                                renderers: void 0,
                                styleMap: f
                            }
                        },
                        featureAdded: w
                    })];
                    C.map.addControls(v);
                    z.events.on({
                        featureselected: b
                    });
                    $("#btnMarkDiv").click(function (a) {
                        $("#toolbag_div").css("display", "none");
                        $("#mark_tool_div").css("display", "block").find(".markClas:eq(0)").addClass("active");
                        u = 0;
                        v[u].activate();
                        $("#mark_tool_div").dialog("open")
                    });
                    $("#mark_close").on("click",
                        function (a) {
                            $("#mark_tool_div .active").removeClass("active");
                            $("#mark_tool_div>.marktool").show();
                            $("#mark_tool_div>.marklist").hide();
                            $("#mark_tool_div").dialog("close");
                            z.removeAllFeatures();
                            v[u].deactivate();
                            markers && markers.removeAllFeatures()
                        });
                    $("#mark_List").on("click",
                        function () {
                            v[u].deactivate();
                            $("#mark_tool_div>.marktool").hide();
                            $("#mark_tool_div>.marklist").show();
                            $("#mark_tool_div").css({
                                width: "260px",
                                height: "280px"
                            });
                            z.removeAllFeatures();
                            z.addFeatures(H)
                        });
                    $("#mark_spin").on("click",
                        function () {
                            v[u].activate();
                            $("#mark_tool_div").css({
                                width: "145px",
                                height: "40px"
                            });
                            $("#mark_tool_div>.marktool").show();
                            $("#mark_tool_div>.marklist").hide();
                            z.removeAllFeatures();
                            z.addFeatures(D)
                        });
                    $(".markClas").on("click",
                        function () {
                            $(".markClas").siblings().removeClass("active");
                            v[u].deactivate();
                            u = $(this).index();
                            $(this).addClass("active");
                            v[u].activate()
                        });
                    $("#mark_quryclear").click(function () {
                        z.removeAllFeatures();
                        H = [];
                        $("#mark_download").css({
                            color: "gray"
                        });
                        $("#mark_result").hide()
                    });
                    $("#mark_qurybtn").click(function () {
                        if (g_userid && "0" != g_userid) {
                            var a = $("#mark_qurytitle").val();
                            $("#mark_download").css({
                                color: "black"
                            });
                            $.ajax({
                                url: Service.GETUserPlot,
                                data: JSON.stringify({
                                    USERID: g_userid,
                                    TITLE: a
                                }),
                                type: "post",
                                success: c,
                                error: function () { },
                                contentType: "application/json; charset=utf-8"
                            })
                        } else alert("当前未登录，请登陆后再查询历史标绘信息！")
                    });
                    $("#mark_download").click(function () {
                        if ("none" != $("#mark_result").css("display")) {
                            var a = [];
                            $("#mark_quryList li :checkbox:checked").each(function () {
                                a.push($(this).parent().attr("id"))
                            });
                            1 > a.length && alert("当前未选中任何标绘！");
                            $.ajax({
                                url: Service.DOWNLOAD,
                                type: "post",
                                dataType: "text",
                                data: {
                                    userid: g_userid,
                                    request: "download",
                                    id: a.join("|") + "|"
                                },
                                success: function (a) {
                                    window.saveFrame && a && (window.saveFrame.location = a, window.imgFrame.document.execCommand("SaveAs"));
                                    return !1
                                },
                                error: function (a, b, d) { }
                            })
                        }
                    });
                    $("#mark_result #mark_quryList").on("dblclick", "li",
                        function () {
                            for (var a = $(this).attr("id"), d = 0; d < H.length; d++) if (H[d].attributes.id == a) {
                                C.map.zoomToExtent(H[d].geometry.getBounds());
                                b({
                                    feature: H[d]
                                });
                                break
                            }
                        });
                    $("#mark_selectall").change(function () {
                        this.checked ? $("#mark_quryList li :checkbox").each(function () {
                            this.checked = !0
                        }) : $("#mark_quryList li :checkbox").each(function () {
                            this.checked = !1
                        })
                    });
                    F = !0
                }
            },
            clear: function () {
                z.removeAllFeatures();
                D = [];
                H = [];
                PoiInfoPop.close()
            }
        }
    }(),
    POI_ICON_SIZE = [],
    POI_IMGOFFSET = [],
    CLASSICON = [["blank", -125, -205, 2, 2], ["yiyuan", -5, -5, 14, 14], ["jiguan", -5, -25, 9, 13], ["danwei", -5, -45, 9, 13], ["xuexiao", -5, -65, 14, 14], ["daxue", -5, -85, 15, 14], ["youeryuan", -5, -105, 15, 15], ["gongyuan", -5, -125, 17, 15], ["dongwuyuan", -5, -145, 17, 15], ["lingyuan", -5, -165, 17, 15], ["fengjing", -5, -185, 15, 13], ["zhiwuyuan", -25, -5, 16, 14], ["guangchang", -25, -25, 17, 15], ["youleyuan", -25, -45, 17, 15], ["binguan", -25, -65, 16, 14], ["tiyuchang", -25, -85, 16, 16], ["xiaoqu", -25, -105, 15, 14], ["changguan", -25, -125, 16, 14], ["chaoshi", -25, -145, 17, 15], ["juyuan", -25, -165, 17, 15], ["gongyeyuan", -25, -185, 19, 17], ["changkuang", -45, -5, 16, 14], ["yisilan", -45, -25, 14, 13], ["jidu", -45, -45, 16, 14], ["shimao", -45, -65, 16, 14], ["dian", -45, -85, 9, 9], ["zhengfu", -45, -105, 13, 13], ["jichang", -45, -125, 19, 17], ["gangkou", -45, -145, 17, 15], ["qichezhan", -45, -165, 17, 15], ["shoufeizhan", -45, -185, 16, 14], ["fuwuqu", -65, -5, 16, 14], ["cesuo", -65, -25, 17, 15], ["tongxin", -65, -45, 16, 14], ["liantong", -65, -65, 15, 13], ["yidong", -65, -85, 16, 14], ["dianxin", -65, -105, 15, 13], ["tingchechang", -65, -125, 16, 14], ["gaosurukou", -65, -145, 17, 11], ["gaosuchukou", -65, -165, 17, 11], ["atm", -65, -185, 17, 11], ["jiayouzhan", -85, -5, 15, 13], ["kfc", -85, -25, 13, 13], ["maidanglao", -85, -45, 13, 9], ["youju", -85, -65, 16, 14], ["dianshitai", -85, -85, 16, 14], ["gouwu", -85, -105, 16, 14], ["yinhang", -85, -125, 16, 14], ["chaguan", -85, -145, 15, 13], ["canyin", -85, -165, 14, 12], ["qiche", -85, -185, 14, 12], ["huochezhan", -105, -5, 15, 15], ["dasha", -105, -25, 15, 11]]; (function () {
        var l, c, m;
        for (m in CLASSICON) {
            for (l = 0; l < POI_ICON_SIZE.length && (c = POI_ICON_SIZE[l], c.w != CLASSICON[m][3] || c.h != CLASSICON[m][4]); l++);
            l == POI_ICON_SIZE.length && POI_ICON_SIZE.push({
                w: CLASSICON[m][3],
                h: CLASSICON[m][4]
            });
            POI_IMGOFFSET[CLASSICON[m][0]] = {
                x: CLASSICON[m][1],
                y: CLASSICON[m][2],
                s: l
            }
        }
    })();
var PoiMarker2 = function (l, c, m) {
    function g() {
        11 > r.zoom && f(POI_IMGOFFSET.blank, 2);
        if (q) {
            var b = r.getLayerPxFromLonLat(q.lonlat);
            a({
                x: b.x - C.w / 2,
                y: b.y - C.h / 2
            },
                2)
        }
    }
    function h() {
        f(POI_IMGOFFSET.blank, 2);
        q = null
    }
    function k() {
        if (!(11 > r.zoom) && F.visibility) {
            var b = t;
            if (b) {
                var d = new Ol2.LonLat(b.pt);
                q = PoiInfoPop.show("local", d, {
                    poi: !0,
                    name: b.name,
                    address: b.address || "暂无信息",
                    telephone: b.telephone || "暂无信息",
                    catg: b.catg || "",
                    cname: b.cname,
                    id: b.pid
                },
                    h);
                var c = POI_IMGOFFSET[b.type];
                C = d = POI_ICON_SIZE[c.s];
                e(d, 2);
                f(c, 2);
                b = r.getLayerPxFromLonLat(new Ol2.LonLat(b.pt));
                a({
                    x: b.x - d.w / 2,
                    y: b.y - d.h / 2
                },
                    2)
            } else f(POI_IMGOFFSET.blank, 2)
        }
    }
    function b(b) {
        if (!(11 > r.zoom) && F.visibility) {
            var c = r.getLonLatFromViewPortPx(b.xy);
            if (!t || !(new Ol2.Bounds(t.bound)).containsLonLat(c)) if (b = F.getTileInfo(c), b = r.zoom + "_" + b.row + "_" + b.col, v[b]) {
                if (b = u[b], null != b) {
                    var p = !1;
                    if (0 < b.id_num) for (var n in b.uids) if ((new Ol2.Bounds(b.uids[n].bound)).containsLonLat(c)) {
                        var c = POI_IMGOFFSET[b.uids[n].type],
                            p = POI_ICON_SIZE[c.s],
                            q = r.getLayerPxFromLonLat(new Ol2.LonLat(b.uids[n].pt));
                        a({
                            x: q.x - p.w / 2,
                            y: q.y - p.h / 2
                        });
                        e(p);
                        f(c);
                        t = b.uids[n];
                        n = r.getLayerPxFromLonLat(new Ol2.LonLat(t.bound.slice(0, 2)));
                        b = r.getLayerPxFromLonLat(new Ol2.LonLat(t.bound.slice(2)));
                        Ol2.Util.extend(y.style, {
                            display: "block",
                            top: b.y + "px",
                            left: n.x + "px",
                            width: Math.round(b.x - n.x) + "px",
                            height: Math.round(n.y - b.y) + "px"
                        });
                        Ol2.Util.extend(B.style, {
                            display: "block",
                            top: b.y + "px",
                            left: n.x + 20 + "px"
                        });
                        B.textContent = t.name;
                        p = !0;
                        break
                    }
                    p || (f(POI_IMGOFFSET.blank), t = null, Ol2.Util.extend(B.style, {
                        display: "none"
                    }))
                }
            } else v[b] = !0,
                t = null,
                n = b.split("_"),
                $.ajax({
                    url: z + "&tileMatrix=" + n[0] + "&tileRow=" + n[1] + "&tileCol=" + n[2],
                    success: d
                })
        }
    }
    function a(a, b) {
        var d;
        d = 2 == b ? w.children[0] : n.children[0];
        d.style.top = a.y + "px";
        d.style.left = a.x + "px"
    }
    function e(a, b) {
        var d;
        d = 2 == b ? w.children[0].children[0] : n.children[0].children[0];
        d.style.width = a.w + "px";
        d.style.height = a.h + "px"
    }
    function f(a, b) {
        var d;
        d = 2 == b ? w.getElementsByTagName("img")[0] : n.getElementsByTagName("img")[0];
        d.style.left = a.x + "px";
        d.style.top = a.y + "px"
    }
    function d(a) {
        if ((a = eval(a)) && 0 != a.length) {
            var b = a[0][1] + 1,
                d = {};
            d.tileid = a[0][0];
            d.id_num = b;
            d.uids = [];
            for (var e = 1; e < b; e++) {
                var c = sdMap.map.getPixelFromLonLat(new Ol2.LonLat(a[e].slice(3, 5))),
                    f = POI_ICON_SIZE[POI_IMGOFFSET[a[e][1]].s],
                    p = new Ol2.Pixel(c.x - f.w / 2, c.y - f.h / 2),
                    c = new Ol2.Pixel(c.x + f.w / 2, c.y + f.h / 2),
                    p = sdMap.map.getLonLatFromPixel(p),
                    c = sdMap.map.getLonLatFromPixel(c),
                    p = {
                        pid: a[e][0],
                        type: a[e][1],
                        name: a[e][2],
                        pt: a[e].slice(3, 5),
                        address: a[e][9].Trim(),
                        telephone: a[e][10].Trim(),
                        cname: a[e][11],
                        catg: a[e][12],
                        bound: [p.lon, c.lat, c.lon, p.lat]
                    };
                d.uids.push(p)
            }
            u[d.tileid] = d
        }
    }
    var r = l,
        t = null,
        n = null,
        w = null,
        y = null,
        q = null,
        v = [],
        u = [],
        z = m,
        F = null,
        B = null,
        C;
    if (c instanceof Ol2.Layer.WMTS) F = c;
    else throw Error("输入图层不是WMTS图层"); (function () {
        if (void 0 === Ol2.Ex.PoiMarker._unique) Ol2.Ex.PoiMarker._unique = this;
        else throw Error("只允许一个WMTS图层拥有POI识别");
        new Ol2.Events(this);
        r.events.register("mousemove", this, b);
        document.addEventListener ? r.viewPortDiv.addEventListener("click", k, !1) : r.viewPortDiv.attachEvent("onclick", k);
        r.events.register("zoomend", this, g);
        n = Ol2.Util.createDiv("OpenLayers_Marker_1");
        n.innerHTML = "<div style='width:0; height:0; z-index: 750; top: 100px; left: 400px; position: relative;'><div style='position: absolute; margin: 0px; padding: 0px; width: 18px; height: 18px; overflow: hidden;'><img style='left:-164px; top:-162px; position:absolute;'src='../Content/map/images/tb.png'/></div></div>";
        w = Ol2.Util.createDiv("OpenLayers_Marker_2");
        w.innerHTML = n.innerHTML;
        y = Ol2.Util.createDiv("OpenLayers_Mask_1");
        Ol2.Util.extend(y.style, {
            position: "absolute",
            background: "url(../Content/Map/images/blank.gif)",
            zIndex: "750",
            cursor: "pointer"
        });
        B = Ol2.Util.createDiv("OpenLayers_Marker_Siv");
        Ol2.Util.extend(B.style, {
            position: "absolute",
            background: "white",
            whiteSpace: "nowrap",
            border: "1px solid #AEB1F0",
            zIndex: "750"
        });
        var a = Ol2.Util.createDiv("OpenLayers_Marker_Poi"),
            d = Ol2.Util.getElement(r.id + "_OpenLayers_Container");
        a.appendChild(n);
        a.appendChild(w);
        a.appendChild(y);
        a.appendChild(B);
        d.appendChild(a)
    })()
};
Ol2.Ex = Ol2.Ex || {};
Ol2.Ex.PoiMarker = PoiMarker2;
var wholeSearchType = "local";
var DragMoveCtl = function () {
    function l() {
        e && c(f)
    }
    function c(a) {
        f = a;
        document.getElementById("DragMoveText_1").innerText = Math.abs(Math.round(a)) + "米";
        a = b.getLayerPxFromLonLat(new Ol2.LonLat(e.x + a / (12742024 * Math.PI) * 450, e.y));
        var d = document.getElementById("OpenLayers_Control_DragMove_1");
        d.style.top = a.y + "px";
        d.style.left = a.x - 18 + "px"
    }
    function m(a) {
        var d = $(a.currentTarget).offset(),
            h = b.getLonLatFromViewPortPx({
                x: a.clientX - d.left,
                y: a.clientY + d.top
            });
        a = e.x;
        var d = h.lon,
            g = e.y * Math.PI / 180,
            h = h.lat * Math.PI / 180,
            g = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin((g - h) / 2), 2) + Math.cos(g) * Math.cos(h) * Math.pow(Math.sin((a * Math.PI / 180 - d * Math.PI / 180) / 2), 2))),
            g = Math.round(6378137E4 * g) / 1E4;
        0 > d - a && (g *= -1);
        a = g;
        500 <= a ? (5E3 < a ? c(5E3) : c(a), k(e, Math.abs(f))) : -500 >= a && (-5E3 > a ? c(-5E3) : c(a), k(e, Math.abs(f)))
    }
    function g() {
        $(".olMapViewport").on({
            mousemove: m,
            mouseup: h
        });
        document.getElementById("DragMoveBtn_1").style.backgroundPositionX = "-87px";
        a.deactivate()
    }
    function h() {
        $(".olMapViewport").off("mousemove", m);
        $(".olMapViewport").off("mouseup", h);
        b.zoomToExtent(d.getDataExtent());
        document.getElementById("DragMoveBtn_1").style.backgroundPositionX = "0";
        r && r("buffer", 0 < f ? f : -f);
        a.activate()
    }
    function k(a, b) {
        d.removeAllFeatures();
        var e = new Ol2.Feature.Vector(new Ol2.Geometry.Polygon.createRegularPolygon(a, b / (12742024 * Math.PI) * 450, 100, 0)),
            c = Ol2.Util.extend({},
                Ol2.Feature.Vector.style["default"]);
        c.fillColor = "blue";
        c.fillOpacity = .2;
        c.labelAlign = "lb";
        c.labelXOffset = 20;
        c.strokeColor = "red";
        c.strokeOpacity = 1;
        e.style = c;
        var c = new Ol2.Feature.Vector(a),
            f = Ol2.Util.extend({},
                Ol2.Feature.Vector.style["default"]);
        f.externalGraphic = "../Content/map/images/leftDiv/png/0[2].png";
        f.graphicWidth = 19;
        f.graphicHeight = 29;
        f.fillOpacity = 1;
        f.cursor = "pointer";
        c.style = f;
        d.addFeatures([e, c])
    }
    var b, a, e, f = 2E3,
        d, r;
    return {
        init: function (e, c) {
            b = e;
            var f = Ol2.Util.createDiv("OpenLayers_Control_DragMove_1");
            f.innerHTML = '<table border="0" cellpadding="0" cellspacing="0"><tr>   <td><div id="DragMoveBtn_1" style="width:36px; height:20px; z-index: 750;position: relative;overflow: hidden;background:url(../Content/map/images/hr.png)"></div></td>    <td><div id="DragMoveText_1"  style="width: 52px; height:20px; z-index: 750;position: relative;overflow: hidden;background:url(images/hr.png);background-position: -36px 0;line-height: 20px;text-align: center;font-size: 13px;">1243米</div></td></tr></table>';
            d = new Ol2.Layer.Vector("dragLayer", {
                rendererOptions: {
                    zIndexing: !1
                }
            });
            b.addLayer(d);
            r = c;
            f.style.top = "300px";
            f.style.left = "300px";
            f.style.position = "absolute";
            f.style.display = "none";
            Ol2.Util.getElement(b.id + "_OpenLayers_Container").appendChild(f);
            document.getElementById("DragMoveBtn_1").onmousedown = g;
            for (var n in b.controls) if ("olControlNavigation" == b.controls[n].displayClass) {
                a = b.controls[n];
                break
            }
        },
        setCircle: function (a, f) {
            b.events.register("zoomend", this, l);
            e = a;
            document.getElementById("OpenLayers_Control_DragMove_1").style.display = "block";
            c(f);
            k(a, f);
            b.zoomToExtent(d.getDataExtent())
        },
        creatbuffer: function (a) {
            for (var e = 0; e < a.length; e++) {
                var c = Ol2.Util.extend({},
                    Ol2.Feature.Vector.style["default"]);
                c.fillColor = "blue";
                c.fillOpacity = .2;
                c.labelAlign = "lb";
                c.labelXOffset = 20;
                c.strokeColor = "red";
                c.strokeOpacity = 1;
                a[e].style = c
            }
            d.addFeatures(a);
            b.zoomToExtent(d.getDataExtent())
        },
        clear: function () {
            b.events.unregister("zoomend", this, l);
            document.getElementById("OpenLayers_Control_DragMove_1").style.display = "none";
            d.removeAllFeatures();
            e = null
        }
    }
}(),
    ResourceList = function () {
        function l() {
            null != ResourceList.queryNode && "WMS" == ResourceList.queryNode.original.servicetype.toUpperCase() && (ResourceList.queryNode = null, document.detachEvent ? ResourceList.map.viewPortDiv.detachEvent("onclick", c) : ResourceList.map.viewPortDiv.removeEventListener("click", c));
            if (null != ResourceList.selNodeIds) {
                var h = ResourceList.selNodeIds.length;
                0 < h && (h = ResourceList.selNodeIds[h - 1], ResourceList.queryNode = $("#pub_tc_tree").jstree(!0).get_node(h), document.attachEvent ? ResourceList.map.viewPortDiv.attachEvent("onclick", c, !1) : ResourceList.map.viewPortDiv.addEventListener("click", c, !1))
            }
        }
        function c(c) {
            if (g && "WMS" == ResourceList.queryNode.original.servicetype.toUpperCase()) {
                var h = ResourceList.map.getExtent(),
                    h = h.left + "," + h.bottom + "," + h.right + "," + h.top,
                    b = c.xy;
                b || (b = $(ResourceList.map.div).offset(), b = {
                    x: c.clientX - b.left,
                    y: c.clientY - b.top
                });
                var a = ResourceList.map.getLonLatFromPixel(b);
                c = '{"x":' + a.lon + ',"y":' + a.lat + "}";
                var b = ResourceList.map.size,
                    b = b.w + "," + b.h + ",96",
                    e = 15;
                switch (ResourceList.queryNode.original.geometrytype.toUpperCase()) {
                    case "POINT":
                        e = 15;
                        break;
                    case "POLYLINE":
                        e = 5;
                        break;
                    case "POLYGON":
                        e = 0
                }
                h = {
                    imageDisplay: b,
                    sr: ResourceList.map.getProjection().split(":")[1],
                    mapExtent: h,
                    geometry: c,
                    layers: "all:" + ResourceList.queryNode.original.querylayers.join(","),
                    geometryType: "esriGeometryPoint",
                    returnGeometry: !1,
                    tolerance: e,
                    f: "json"
                };
                c = ResourceList.queryNode.original.queryurl + "/identify";
                jQuery.support.cors = !0;

                //注释
                $.ajax({
                    data: h,
                    method: "POST",
                    url: c,
                    success: function (b) {
                        b = JSON.parse(b);
                        null != b.results && 0 < b.results.length && PoiInfoPop.show("resourcelist", a, b.results[0].attributes, null)
                    },
                    error: function (a, b, c) { }
                })
            }
        }
        var m = !1,
            g = !1;
        return {
            init: function (c) {//初始化法律法规数据

                param = {
                    class: 'lawsRegulationss',
                };

                a = encodeURI(Service.jXS + parseParam(param));
                //$.ajax({
                //    dataType: "json",
                //    url: a,
                //    success: function (data) {
                //        var str = "";
                //        for (var i = 0; i < data.length; i++) {
                //            var titleStr = data[i].title;
                //            if (data[i].title.length > 20) {
                //                titleStr = data[i].title.substring(0, 20) + "..";
                //            }
                //            str += "<a id=" + i + " href=\"#\" class=\"list-group-item\" data-id=" + i + " data-toggle=\"modal\" data-target=\"#myModal\" title=" + data[i].title + " data-title=" + data[i].title + "  data-content=" + data[i].content + " >" + titleStr + "</a>";
                //        }
                //        $("#pub_tc_tree").html(str);
                //    }
                //});



                //m || (this.map = c, this.hashLayers = new HashTable, c = $("#pub_tc_tree").jstree({
                //    plugins: ["dnd", "search", "state", "types", "checkbox"],
                //    dnd: {
                //        is_draggable: !1
                //    },
                //    core: {
                //        data: {
                //            url: "../Scripts/map/root.txt?" + (new Date).getTime(),
                //            dataType: "json"
                //        },
                //        check_callback: !0,
                //        strings: {
                //            "Loading ...": "目录加载中..."
                //        },
                //        themes: {
                //            name: !1,
                //            dots: !1,
                //            icons: !1
                //        },
                //        multiple: !0,
                //        icon_style: "normal"
                //    },
                //    types: {
                //        "default": {
                //            valid_children: ["default", "file"]
                //        },
                //        file: {
                //            valid_children: [],
                //            icon: "jstree-file"
                //        }
                //    },
                //    checkbox: {
                //        visible: !0,
                //        three_state: !1,
                //        whole_node: !0,
                //        keep_selected_style: !1
                //    }
                //}), c.on("activate_node.jstree",
                //    function (c, b) {
                //        var a = b.node,
                //            e = $("#pub_tc_tree").jstree(!0);
                //        if (!a || 0 < a.children.length) return e.toggle_node(a),
                //            e.deselect_node(a),
                //            ResourceList.reloadLegend(a.children),
                //            !1;
                //        ResourceList.isOpen(e, a) && ResourceList.addLegend(a);
                //        if (a.state.selected) if (null == ResourceList.selNodeIds && (ResourceList.selNodeIds = []), ResourceList.selNodeIds.push(a.id), ResourceList.hashLayers.contains(a.id)) a = ResourceList.hashLayers.get(a.id),
                //            ResourceList.map.addLayer(a);
                //        else switch (e = a.original, e.servicetype.toUpperCase()) {
                //            case "WMS":
                //                var f = {
                //                    LAYERS: e.layers,
                //                    TRANSPARENT: !0,
                //                    STYLES: "",
                //                    FORMAT: "image/png",
                //                    SRS: ResourceList.map.getProjection()
                //                },
                //                    e = new Ol2.Layer.WMS("themLayer_" + a.id, e.serviceurl, f, {
                //                        isBaseLayer: !1,
                //                        opacity: .7,
                //                        singleTile: !0
                //                    });
                //                ResourceList.map.addLayer(e);
                //                ResourceList.hashLayers.put(a.id, e)
                //        } else null != ResourceList.selNodeIds && ResourceList.selNodeIds.arryRemove(a.id),
                //            ResourceList.hashLayers.contains(a.id) && (a = ResourceList.hashLayers.get(a.id), ResourceList.map.removeLayer(a)),
                //            null != ResourceList.selNodeIds && 0 == ResourceList.selNodeIds.length && PoiInfoPop.close();
                //        l()
                //    }), c.on("ready.jstree",
                //        function (c, b) {
                //            var a = $("#pub_tc_tree").jstree(!0);
                //            a.deselect_node(a.get_selected());
                //            a.close_all()
                //        }), $("#tab_resource_identi").click(function () {
                //            g = $(":checkbox", this)[0].checked ? !0 : !1
                //        }), m = !0)
            },
            //renderByChildrenNode: function (c) {
            //    c = $("#pub_tc_tree").jstree(!0);
            //    $("#pub_tc_tree").find("*").removeClass("jstree-selected-inthat-parent-div").removeClass("jstree-selected-inthat-parent-span");
            //    for (var h = c.get_selected(), b = 0, a = h.length; b < a; b++) {
            //        var e = c.get_node(h[b]);
            //        ResourceList._renderRowWByChildren(e.id);
            //        var f = c.get_parent(e);
            //        ResourceList._renderRowWByChildren(f);
            //        e = c.get_node(e.parent).parent;
            //        ResourceList._renderRowWByChildren(e)
            //    }
            //},
            //_renderRowWByChildren: function (c, k) {
            //    if ("#" !== c) {
            //        var b = $("#pub_tc_tree").find("#" + c + " .jstree-wholerow:first"),
            //            a = $("#pub_tc_tree").find("#" + c).find("a:first span");
            //        b.addClass("jstree-selected-inthat-parent-div");
            //        a.addClass("jstree-selected-inthat-parent-span")
            //    }
            //},
            //addLegend: function (c) {
            //    if (c) {
            //        var h = "#" + c.id + ">.jstree-legend";
            //        0 < $(h).children().length && $(h).empty();
            //        if (c.state.selected) {
            //            var h = c.original.queryurl || c.original.serviceurl.replace(/arcgis\/services/, "arcgis/rest/services/").replace(/WMSServer/, ""),
            //                b;
            //            $.ajax({
            //                url: h + "/legend?f=pjson",
            //                cache: !0,
            //                dataType: "json",
            //                success: function (a) {
            //                    b = a;
            //                    a = document.createElement("DIV");
            //                    if (b) for (var e = c.original.querylayers || [b.layers.length - 1 - c.original.layers[0]], f = 0; f < b.layers.length; f++) if (b.layers[f].layerId == e[0]) {
            //                        for (var e = b.layers[f], f = [], d = 0; d < e.legend.length; d++) f.push("<div><img src='data:" + e.legend[d].contentType + ";base64," + e.legend[d].imageData + "'><span>" + e.legend[d].label + "</span></div>");
            //                        $(a).append(f.join(""));
            //                        a.className = "jstree-legend";
            //                        document.getElementById(c.id).appendChild(a);
            //                        break
            //                    }
            //                }
            //            })
            //        }
            //    }
            //},
            //removeLegend: function (c) {
            //    if (c) {
            //        var h = "#" + c.id + ">.jstree-legend"; (0 < $(h).children().length || !c.state.selected) && $(h).empty()
            //    }
            //},
            //reloadLegend: function (c) {
            //    var h = $("#pub_tc_tree").jstree(!0);
            //    c = c ? c : h.get_selected();
            //    $A.forEach(c,
            //        function (b) {
            //            ResourceList.addLegend(h.get_node(b))
            //        })
            //},
            //isOpen: function (c, g) {
            //    var b = c.get_parent(g);
            //    return "#" == b ? !0 : c.get_node(b).state.opened ? this.isOpen(c, b) : !1
            //},
            //getTreeStatusInfo: function () {
            //    var c = $("#pub_tc_tree").jstree(!0),
            //        g = $("#pub_tc_tree").jstree(!0).get_selected(),
            //        b = [];
            //    window.sort_nodes && $A.forEach(sort_nodes,
            //        function (a) {
            //            a = [a].concat(c.get_node(a).children);
            //            b.push(a.join("-"))
            //        });
            //    return g.join(",") + "|" + b.join(",")
            //},
            //cancelSelectNode: function () {
            //    for (var c = $("#pub_tc_tree").jstree(!0), g = c.get_selected(), b = g.length - 1; 0 <= b; b--) if (ResourceList.removeLegend(c.get_node(g[b])), ResourceList.hashLayers.contains(g[b])) {
            //        var a = ResourceList.hashLayers.get(g[b]);
            //        ResourceList.map.removeLayer(a)
            //    }
            //    c.deselect_node(c.get_selected());
            //    ResourceList.selNodeIds = null;
            //    l()
            //}
        }
    }(),
    RightMenu = function () {
        var l, c = !1,
            m;
        return {
            init: function (g) {
                c || (l = g, $(".olMapViewport").mouseup(function (c) {
                    if (3 == c.which) {
                        var g, b = $(this).offset();
                        g = c.clientX - b.left;
                        c = c.clientY - b.top;
                        m = l.map.getLonLatFromPixel(new Ol2.Pixel(g, c));
                        $("#rightDiv").css({
                            display: "block",
                            left: g + 2,
                            top: c
                        })
                    }
                }).click(function () {
                    $("#rightDiv").hide()
                }).after("<div id = 'rightDiv'>\t<ul>\t\t<li id = 'right_from' style = 'margin-top:3px;'>以此为起点</li>\t    <li id = 'right_to'  >以此为终点</li>\t    <li id = 'right_around' style='height:23px;'><div class='splitline'>在此点附近找...</div></li>     \t\t<li id = 'right_zoomin' >放大</li>\t\t<li id = 'right_zoomout' >缩小</li>       <li id = 'right_addcorrect' ><div class='splitline' style='border-bottom:none'>数据错误反馈...</div></li>\t</ul></div>"), $("#rightDiv li").click(function () {
                    $("#rightDiv").css("display", "none");
                    switch (this.id) {
                        case "right_from":
                            switchSearch("s3");
                            PathSearch.setStart(new Ol2.Feature.Vector(new Ol2.Geometry.Point(m.lon, m.lat)), 2);
                            break;
                        case "right_to":
                            switchSearch("s3");
                            PathSearch.setEnd(new Ol2.Feature.Vector(new Ol2.Geometry.Point(m.lon, m.lat)), 2);
                            break;
                        case "right_around":
                            PoiInfoPop.show("around", m);
                            break;
                        case "right_zoomout":
                            l.map.zoomOut();
                            break;
                        case "right_zoomin":
                            l.map.zoomIn();
                            break;
                        case "right_addcorrect":
                            MapCorrect.openCorrect({
                                TYPE:
                                    0,
                                LNG: m.lon,
                                LAT: m.lat
                            })
                    }
                }), c = !0)
            }
        }
    }(),
    WholeSearch = function () {//地图左侧列表拼接
        function l(a, b) {
            var d = w.length;
            if (0 == d) $("#item").empty();
            else {
                var c, f = (a - 1) * b;
                c = f + b >= d ? d : f + b;
                if (q != a) for (var p = f + b >= d ? d : f + b, d = (q - 1) * b; d < p; d++) w[d].style = e;
                q = a;
                y.redraw();

                for (var p = ["<ul style='list-style:none'>"], n = 1, d = f; d < c; d++) f = w[d].attributes,
                    p.push("<li idx=" + n + " class='itemClass'>"),
                    p.push("<div class='itemIcon' style='background-position: " + -21 * (n - 1) + "px 0px;'></div>"),
                    p.push("<p class='pName' style='line-height: 20px;'>"),
                    p.push(w[d].attributes.name + "&nbsp;>>" + (null != w[d].attributes.geometry && "" != f.class_text ? "<span class='pType'>" + f.class_text + "</span>" : "")),
                    p.push("</p>"),
                    f.distance && p.push("<p class='pDistance'>" + f.distance + "</p>"),
                    "暂无记录" != f.address && p.push("<p class='pAddress_Phone'>地址:" + f.address + "</p>"),
                    "暂无记录" != f.telephone && p.push("<p class='pAddress_Phone'>电话:" + f.telephone + "</p>"),
                    //p.push("<p class='pBottom'><a class='poi_correct' onclick='MapCorrect.openCorrect({TYPE:1,LSID:\"" + f.lsid + "\"})'href='javascript:void(0)'><img class='correct_jiu' alt='纠错' src='../Content/Map/images/leftDiv/icon_qipao_correct.png'>纠错</a></p>"),
                    p.push("</li>"),
                    f = Ol2.Util.extend({},
                        Ol2.Feature.Vector.style["default"]),

                    f.externalGraphic = "../Content/map/images/leftDiv/ball/r(" + n + ").png",
                    f.graphicWidth = 21,
                    f.graphicHeight = 33,
                    f.fillOpacity = 1,
                    f.cursor = "pointer",
                    w[d].style = f,
                    y.drawFeature(w[d]),
                    n++;
                p.push("</ul>");
                $("#item").empty().append(p.join(""))
            }
        }
        function c() {
            n.map.events.on({
                moveend: function () {
                    if (t && v && !v.radius) {
                        var b = n.map.getExtent();
                        v.area = "RECT(" + b.left + " " + b.bottom + "," + b.right + " " + b.top + ")";
                        a("local", v)
                    }
                }
            });
            var b = function () {
                $("#poiSearch_suglist").hide()
            };
            document.attachEvent ? n.map.viewPortDiv.attachEvent("onclick", b, !1) : n.map.viewPortDiv.addEventListener("click", b, !1);
            y.events.on({
                featureselected: function (a) {
                    a.feature.attributes && PoiInfoPop.show(wholeSearchType, a.feature.geometry, a.feature.attributes)
                }
            });
            $("#left_query_btn").click(function (b) {
                PoiInfoPop.close();

                var code = $("#hidCode").val();
                if (code == "") {
                    //alert("请先选择左侧菜单模块，再进行搜索！");
                    $('#alertModal').modal('toggle');
                    return;
                }

                if (b = $("#left_query_text").val()) z = !0,
                    $("#resultCount").text("正在搜索...."),
                    switchSearch("s2"),
                    $("#textlist").hide(),
                    t = !0,
                    v = {
                        words: b,
                        pagecap: 50
                    },
                    a("local", {
                        words: b,
                        pagecap: 50,
                        class: code
                    })
            });
            //$("#left_query_text").keyup(function (b) {
            //    13 == b.which ? ($("#left_query_btn").click(), $("#poiSearch_suglist").hide(), F = !1, clearTimeout(B)) : (F || (B = setTimeout(function () {
            //        F = !1;
            //        var b = $("#left_query_text").val().Trim();
            //        "" != b && ($("#textlist").show(), a("list", {
            //            words: b
            //        },
            //            h))
            //    },
            //        300), F = !0), "" == $(this).val().Trim() && ($("#poiSearch_suglist").hide(), $(document).unbind("click", m)))
            //});
            $("#textlist").on("click", ".textlistitem",
                function (b) {
                    PoiInfoPop.close();
                    $("#left_query_text").val($(this).text());
                    $("#textlist").hide();
                    $("#pageId").empty();
                    $("#item").empty();
                    switchSearch("s2");
                    a("obtain", {
                        fid: $(this).attr("id")
                    })
                });
            $("#textlist").on("click", "#textlistclose",
                function () {
                    $("#textlist").hide()
                });

            //地图左侧菜单模块点击事件
            $(".fenleiClass").click(function (b) {
                wholeSearchType = "local";
                f = $(this).attr("code");

                var userType = "";
                if ($(this).attr("data-userType") != null) {
                    userType = $(this).attr("data-userType");
                }

                //隐藏域code值
                $("#hidCode").val(f);

                b = $(this).text().trim();
                $("#resultCount").text("正在搜索....");
                //$("#left_query_text").val(b);
                switchSearch("s2");
                $("#item").empty();
                b = n.map.getExtent();
                v = {
                    area: "RECT(" + b.left + " " + b.bottom + "," + b.right + " " + b.top + ")",
                    "class": f,
                    pagecap: 200,
                    userType: userType
                };
                t = !0;
                a("local", v)
            });
            //返回点击事件
            $("#returnBtn").click(function (a) {
                null != y && (y.removeAllFeatures(), u.removeAllFeatures());
                PoiInfoPop.close();
                $("#item").empty();
                v = null;
                $("#left_query_text").val("");
                switchSearch("s1");
                $("#hidCode").val("");//清空隐藏域的值
            });
            $("#item").on("mouseenter", ".itemClass",
                function () {
                    var a = $(this),
                        b = a.attr("idx"),
                        a = a.find("div:eq(0)");
                    a.css("background-position", a.css("background-position").split(" ")[0] + " -66px");
                    a = 10 * (q - 1) + parseInt(b) - 1;
                    w[a].style.externalGraphic = "../Content/map/images/leftDiv/ball/b (" + b + ").png";
                    y.drawFeature(w[a])
                });
            $("#item").on("mouseleave", ".itemClass",
                function (a) {
                    var b = $(this);
                    a = b.attr("idx");
                    b = b.find("div:eq(0)");
                    b.css("background-position", b.css("background-position").split(" ")[0] + " 0px");
                    b = 10 * (q - 1) + parseInt(a) - 1;
                    w[b].style.externalGraphic = "../Content/map/images/leftDiv/ball/r(" + a + ").png";
                    y.drawFeature(w[b])
                });
            $("#item").on("click", ".itemClass",
                function () {
                    PoiInfoPop.close();
                    var a = t;
                    t = !1;
                    var b = parseInt($(this).attr("idx")),
                        b = 10 * (q - 1) + b - 1,
                        d = w[b].geometry;
                    PoiInfoPop.show("local", w[b].geometry, w[b].attributes);
                    u.features.length > b ? n.map.zoomToExtent(u.features[b].geometry.getBounds()) : n.map.setCenter(new Ol2.LonLat(d.x, d.y), 14);
                    t = a
                });
            //一键报警列表
            $("#dropdownMenu1").click(function (b) {
                wholeSearchType = "police";
                if (anumber == 1) {
                    anumber = 0;
                    $.ajax({
                        type: "GET",
                        url: "GetCallPolices",
                        dataType: "json",
                        success: function (result) {

                            y.removeAllFeatures();
                            u.removeAllFeatures();
                            w = [];
                            var data = result.result;

                            $("#dropdown-menu").empty();
                            if (data.length > 0) {


                                var dropdownContent = '<dt>报警列表</dt><div id="myList">';
                                $.each(data, function (i, item) {
                                    dropdownContent += '<dd idx=' + i + ' class="itemcallpolice"><span class="pull-left">报警人：</span>' + item.creatUserName +
                                        '<span class="pull-right">' + new Date(item.creationTime).toLocaleString() + '</span></dd>';
                                    var e = new Ol2.Feature.Vector(new Ol2.Geometry.Point(parseFloat(item.xPoint), parseFloat(item.yPoint)), item);
                                    e.attributes.address = item.address;
                                    e.attributes.telephone = "暂无记录";
                                    w.push(e);
                                });
                                dropdownContent += "</div>";
                                //加入图层
                                y.addFeatures(w);
                                //展示
                                $.each(data, function (i, item) {
                                    f = Ol2.Util.extend({},
                                        Ol2.Feature.Vector.style["default"]),

                                        f.externalGraphic = "../Content/map/images/leftDiv/ball/r(1).png",
                                        f.graphicWidth = 21,
                                        f.graphicHeight = 33,
                                        f.fillOpacity = 1,
                                        f.cursor = "pointer",
                                        item.style = f,
                                        y.drawFeature(item)
                                });

                                $("#dropdown-menu").append(dropdownContent);
                                $("#dropdown-menu").show();

                            }
                            else {
                                $(".baojing").show();
                                $(".baojin").hide();
                                var myAudio = document.getElementById("myaudio");
                                myAudio.pause();
                            }
                        },
                        error: function (b, a) {
                            console.log && console.log("矛盾纠纷数据请求" + a)
                        }
                    });
                } else {
                    $("#dropdown-menu").hide();
                    anumber = 1;
                }
            });
            $("#dropdown-menu").on("click", ".itemcallpolice",
                function () {
                    var a = t;
                    t = !1;
                    var b = parseInt($(this).attr("idx")),
                        d = w[b].geometry;
                    PoiInfoPop.show("police", w[b].geometry, w[b].attributes);
                    t = a
                });
        }
        function m(a) {
            a = a || window.event;
            0 == $(a.target).closest("#poiSearch_suglist").length && ($("#poiSearch_suglist").hide(), $(document).unbind("click", m))
        }
        function g() {
            var d = $(this).attr("crd").split(";");
            t = !1;
            $("#left_query_text").val(d[3]);
            a("obtain", {
                lsid: d[2]
            },
                function (a) {
                    switchSearch("s2");
                    k(a.result.features);
                    0 < a.result.entitytotal && b([a.result.features[0]], !0);
                    t = !0
                });
            n.map.setCenter(new Ol2.LonLat(parseFloat(d[0]), parseFloat(d[1])));
            $("#poiSearch_suglist").hide()
        }
        function h(a) {
            var b = $("#left_query_text").offset();
            $("#poiSearch_suglist").empty().append(a).show().css({
                left: b.left + "px",
                top: b.top + 28 + "px"
            }).children("div").click(g);
            $(document).bind("click", m)
        }
        function k(a) {
            y.removeAllFeatures();
            u.removeAllFeatures();
            w = [];
            var b = a.length;
            $("#resultCount").html("&nbsp;共有" + b + "条结果");
            for (var c = 0; c < b; c++) {
                var e = new Ol2.Feature.Vector(new Ol2.Geometry.Point(parseFloat(a[c].lng), parseFloat(a[c].lat)), a[c]);
                e.attributes.address = e.attributes.address || (e.attributes.district_text ? e.attributes.district_text.replace(/(山东省|市辖区)|>/g, "") : "暂无记录");
                e.attributes.telephone = e.attributes.telephone || "暂无记录";
                w.push(e)
            }
            y.addFeatures(w);
            q = 1;
            d.doPage(q, w.length)
        }
        function b(a, b) {
            for (var d = [], c = 0; c < a.length; c++) {
                var e = a[c],
                    e = (new Ol2.Format.WKT).read(e.geometry);
                d.push(e)
            }
            0 < d.length && (Util.HighlightGeo(u, d), b && (z = !1, n.map.zoomToExtent(d[0].geometry.getBounds())))
        }

        function k1(a) {
            y.removeAllFeatures();
            u.removeAllFeatures();
            w = [];
            var b = a.length;
            $("#resultCount").html("&nbsp;共有" + b + "条结果");
            for (var c = 0; c < b; c++) {
                var e = new Ol2.Feature.Vector(new Ol2.Geometry.Point(parseFloat(a[c].lng), parseFloat(a[c].lat)), a[c]);
                e.attributes.address = e.attributes.address || (e.attributes.district_text ? e.attributes.district_text.replace(/(山东省|市辖区)|>/g, "") : "暂无记录");
                e.attributes.telephone = e.attributes.telephone || "暂无记录";
                w.push(e)
            }
            y.addFeatures(w);
            q = 1;
            d.doPage(q, w.length)
        }
        function b1(a, b) {
            for (var d = [], c = 0; c < a.length; c++) {
                var e = a[c],
                    e = (new Ol2.Format.WKT).read(e.geometry);
                d.push(e)
            }
            0 < d.length && (Util.HighlightGeo(u, d), b && (z = !1, n.map.zoomToExtent(d[0].geometry.getBounds())))
        }

        //获取后台数据
        function a(a, d, c) {
            switch (a) {
                case "local":

                    a = encodeURI(Service.jXS + parseParam(d));
                    $.ajax({
                        dataType: "json",
                        url: a,
                        success: function (a) {

                            k(a.result.features);
                            b(a.result.features.slice(0, a.result.entitytotal), z);
                            "function" == typeof c && c(a)
                        }
                    });
                    break;
                case "police":
                    a = "GetCallPolices";
                    $.ajax({
                        dataType: "json",
                        url: a,
                        success: function (a) {

                            k1(a.result);
                            b1(a.result.features.slice(0, a.result.entitytotal), z);
                            "function" == typeof c && c(a)
                        }
                    });
                    break;
                case "buffer":
                    "object" == typeof d ? v = d : v.radius = d;
                    a = encodeURI(Service.LS + parseParam(v));
                    $.ajax({
                        dataType: "jsonp",
                        url: a,
                        success: function (a) {
                            k(a.result.features);
                            "function" == typeof c && c(a)
                        }
                    });
                    break;
                case "rgc2":
                    a = encodeURI(Service.RGC2 + parseParam(d));
                    $.ajax({
                        dataType: "jsonp",
                        url: a,
                        success: function (a) {
                            "function" == typeof c && c(a)
                        }
                    });
                    break;
                case "list":
                    a = encodeURI(Service.LS + parseParam(d));
                    $.ajax({
                        dataType: "jsonp",
                        url: a,
                        success: function (a) {
                            if ("function" == typeof c) {
                                a = a.result.features;
                                for (var b = [], e = 0; e < a.length; e++) {
                                    var f = a[e].name,
                                        f = f.replace(d.words, "<b>" + d.words + "</b>"),
                                        f = "<span class='poi_tip_name'>" + f + "&nbsp;</span>",
                                        n = a[e].district_text ? a[e].district_text.replace(/(山东省|市辖区)|>/g, "") : "";
                                    if ("" != n) var n = n.replace(d.words, "<b>" + d.words + "</b>"),
                                        n = "<span class='poi_tip_district'>" + n + "</span>",
                                        v = "";
                                    null != a[e].geometry && "" != a[e].class_text && (v = "<span class='poi_tip_type'>" + a[e].class_text + "</span>");
                                    b.push("<div crd='" + a[e].lng + ";" + a[e].lat + ";" + a[e].lsid + ";" + a[e].name + "'>" + f + n + v + "</div>")
                                }
                                b.push("<hr style='height:1px;border:none;border-top: 1px #ebebeb solid;'></hr><a id='poiSearch_suglistclose' title='关闭' href='javascript:void(0)' >关闭</a>");
                                c(b.join(""))
                            }
                        }
                    });
                    break;
                case "obtain":
                    a = encodeURI(Service.LSID + parseParam(d)),
                        $.ajax({
                            dataType: "jsonp",
                            url: a,
                            success: function (a) {
                                "function" == typeof c && c(a)
                            }
                        })
            }
        }
        var e, f, d, r = !1,
            t = !0,
            n, w = [],
            y,
            q = 1,
            v,
            u,
            z = !1,
            F = !1,
            B;
        return {
            clearResult: function () {
                null != y && y.removeAllFeatures();
                n.graLayer.removeAllFeatures();
                u.removeAllFeatures();
                PoiInfoPop.close();
                $("#item").empty();
                v = null;
                $("#left_query_text").val("")
            },
            request: a,
            init: function (a) {
                r || (n = a,
                    e = Ol2.Util.extend({}, Ol2.Feature.Vector.style["default"]),
                    e.pointRadius = 4,
                    e.fillColor = "#0000ff",
                    e.fillOpacity = .3,
                    e.strokeColor = "#0000ff",
                    e.strokeOpacity = .4,
                    e.strokeWidth = 4,
                    e.cursor = "pointer",
                    e.externalGraphic = "../Content/map/images/leftDiv/ball/r.png",
                    e.graphicOpacity = 1,
                    e.graphicHeight = e.graphicWidth = 8,
                    u = new Ol2.Layer.Vector("entityLayer", {
                        style: e,
                        rendererOptions: {
                            zIndexing: !0
                        }
                    }),
                    n.addLayer(u),
                    y = new Ol2.Layer.Vector("seach", {
                        style: e,
                        rendererOptions: {
                            zIndexing: !0
                        }
                    }),
                    n.addLayer(y, !0),
                    $("#tab_search_div2").append("<div class='poisearch_result_head'>    搜索结果<input id = 'returnBtn' class='poisearch_result_return' type = 'button' value = '返回'/></div><div id = 'resultCount'>正在搜索....</div><div id = 'item' class = 'poisearch_list'></div><div class='pageDiv' id='wholepageDiv' style='width:100%;bottom:15px;position:absolute;'><ul class='page'></ul></div>"),
                    d = new PageCtl,
                    d.init("wholepageDiv", l, 10),
                    0 == $("#poiSearch_suglist").length && ($(document.body).append("<div id='poiSearch_suglist' style='position:absolute;display:none;'></div>"),
                        $("#poiSearch_suglist").delegate("a", "click", function () {
                            $("#poiSearch_suglist").hide()
                        })),
                    c(),
                    r = !0)
            }
        }
    }(),
    PathSearch = function () {
        var l = null,
            c = null,
            m = 0,
            g = 0,
            h = !1,
            k = null,
            b = null,
            a = null,
            e = null,
            f = null,
            d = null,
            r = null,
            t = null,
            n = -1,
            w = null,
            y = null,
            q = [],
            v = [],
            u = [],
            z = [],
            F = null,
            B = null,
            C = null,
            p = null,
            E = null,
            G = null,
            I = {
                fillOpacity: 1,
                fillColor: "blue",
                strokeOpacity: 1,
                strokeColor: "blue",
                pointRadius: 3
            },
            A = {
                ConvertToP: function (a) {
                    for (var b = [], d = a.length / 10, c, e, f, n = 0; n < d; n++) c = 10 * n,
                        e = c + 5,
                        f = e + 5,
                        c = a.substring(c, e),
                        e = a.substring(e, f),
                        c = parseInt(c, 36) / 1E5,
                        e = parseInt(e, 36) / 1E5,
                        b.push(c),
                        b.push(e);
                    return b
                },
                ClipSeg: function (a, b, d) {
                    var c = A.floorTo(a[0], 5);
                    a = A.floorTo(a[1], 5);
                    var e = A.floorTo(b[0], 5);
                    b = A.floorTo(b[1], 5);
                    for (var f = -1,
                        n = -1,
                        v = d.length / 2,
                        q = 0; q < v; q++) {
                        var p = 2 * q,
                            g = p + 1; -1 == f ? d[p] == c && d[g] == a && (f = q) : d[p] == e && d[g] == b && (n = q)
                    }
                    return -1 != f && -1 != n ? d.slice(2 * f, 2 * n + 2) : null
                },
                floorTo: function (a, b) {
                    var d = a + "",
                        c = d.indexOf("."),
                        e = d.length;
                    return -1 == c || 6 >= e - c ? a : parseFloat(d.substring(0, c + 6))
                },
                exceptionHandler: function () {
                    e.removeAllFeatures();
                    e.refresh();
                    A.switchLayerZIndex(f, e);
                    G.deactivate();
                    G.activate();
                    $("#distanceLabel").hide();
                    $("#pathListdiv").html("<div style='font-size:14px;padding:15px;color:#0070E6;margin-left:10px;'>无导航结果，请重新设置路线...</div>")
                },
                requestData: function (a) {
                    var b = $("#paramDiv #p_type :checked").val();
                    "nohign" == b ? (a.highway = 0, a.type = 1) : "fast" == b && (a.type = 1);
                    try {
                        $("#distanceLabel").hide(),
                            $("#pathListdiv").html("正在查询..."),
                            $.ajax({
                                url: Service.PATH + parseParam(a),
                                dataType: "jsonp",
                                success: A.parseData,
                                error: function (a, b) {
                                    A.exceptionHandler()
                                }
                            })
                    } catch (H) {
                        A.exceptionHandler()
                    }
                },
                parseData: function (a, d, c) {
                    if ("success" == d && (z = A.ConvertToP(a.result.route.routetxt), e.removeAllFeatures(), f.removeAllFeatures(), "ok" == a.status && a.result.events && 0 != a.result.events.length)) {
                        d = a.result;
                        $("#distanceLabel").text("驾车路线        约" + a.result.distance + ".");
                        $("#distanceLabel").css("display", "block");
                        if (d.route) {
                            var n = [],
                                q;
                            turf.point([l.geometry.x, l.geometry.y]);
                            c = [];
                            a = 0;
                            for (var p = z.length; a < p; a += 2) n.push(new Ol2.Geometry.Point(z[a], z[a + 1])),
                                c.push([z[a], z[a + 1]]);
                            a = Ol2.Util.extend({},
                                Ol2.Feature.Vector.style["default"]);
                            a.strokeColor = "#3231fb";
                            a.strokeOpacity = 1;
                            a.strokeWidth = 3;
                            a.cursor = "pointer";
                            w = new Ol2.Feature.Vector(new Ol2.Geometry.LineString(n));
                            w.style = a;
                            e.addFeatures(w);
                            r.removeAllFeatures();
                            DrawFlowPath(w.geometry, r);
                            f.addFeatures(u);
                            a = Ol2.Util.extend({},
                                Ol2.Feature.Vector.style["default"]);
                            a.strokeColor = "#0000ff";
                            a.strokeOpacity = .8;
                            a.strokeWidth = 3;
                            a.strokeDashstyle = "dot";
                            a.cursor = "pointer";
                            c = {
                                type: "Feature",
                                properties: {},
                                geometry: {
                                    type: "LineString",
                                    coordinates: c
                                }
                            };
                            for (var p = f.features,
                                n = [], g = 0, h = p.length; g < h; g++) {
                                var k = p[g].geometry;
                                q = turf.point([k.x, k.y]);
                                q = turf.pointOnLine(c, q);
                                k = new Ol2.Feature.Vector(new Ol2.Geometry.LineString([k, new Ol2.Geometry.Point(q.geometry.coordinates[0], q.geometry.coordinates[1])]));
                                k.style = a;
                                n.push(k)
                            }
                            e.addFeatures(n);
                            b.map.zoomToExtent(w.geometry.getBounds());
                            A.pathStartEdit()
                        }
                        c = [];
                        d = d.events;
                        n = !1;
                        a = 0;
                        for (p = d.length; a < p; a++) {
                            g = d[a];
                            0 == a && (g.eventprompt = g.eventprompt.replace("沿无名道路", ""));
                            k = 0;
                            0 < g.nextdistance.search("公里") ? k = 1E3 * g.nextdistance.replace("公里", "") : 0 < g.nextdistance.search("米") && (k = g.nextdistance.replace("米", ""));
                            if (n) if ("" == g.roadname) {
                                if ("直行" == g.turntype) {
                                    h = c.length - 1;
                                    q = c[h].nextdistance;
                                    0 < q.search("米") ? k = parseInt(k) + parseInt(q.replace("米", "")) : 0 < q.search("公里") && (k = parseInt(k) + 1E3 * parseInt(q.replace("公里", "")));
                                    k = 1E3 < k ? k / 1E3 + "公里" : k + "米";
                                    c[h].eventprompt = c[h].eventprompt.replace(c[h].nextdistance, k);
                                    c[h].nextdistance = k;
                                    continue
                                }
                            } else {
                                n = !1;
                                h = c.length - 1;
                                q = c[h].nextdistance;
                                var m = 0;
                                0 < q.search("米") ? m = parseInt(q.replace("米", "")) : 0 < q.search("公里") && (m = 1E3 * parseInt(q.replace("公里", "")));
                                if (("直行" == g.turntype || 0 <= g.turntype.search("偏") && g.turntype == c[h].turntype) && 20 > m && "直行" != c[h].turntype) {
                                    0 < q.search("米") ? k = parseInt(k) + parseInt(m) : 0 < q.search("公里") && (k = parseInt(k) + parseInt(m));
                                    k = 1E3 < k ? k / 1E3 + "公里" : k + "米";
                                    c[h].roadname = g.roadname;
                                    c[h].eventprompt = c[h].eventprompt.replace(c[h].nextdistance, k).replace("无名道路", g.roadname);
                                    0 <= g.turntype.search("偏") && (c[h].turntype = c[h].turntype.replace("偏", ""), c[h].eventprompt = c[h].eventprompt.replace("偏", ""));
                                    c[h].nextdistance = k;
                                    continue
                                }
                            } else if ("" == g.roadname && (n = !0, "直行" == g.turntype && 50 > k)) {
                                h = c.length - 1;
                                q = c[h].nextdistance;
                                0 < q.search("米") ? k = parseInt(k) + parseInt(q.replace("米", "")) : 0 < q.search("公里") && (k = parseInt(k) + 1E3 * parseInt(q.replace("公里", "")));
                                k = 1E3 < k ? k / 1E3 + "公里" : k + "米";
                                c[h].eventprompt = c[h].eventprompt.replace(c[h].nextdistance, k);
                                c[h].nextdistance = k;
                                continue
                            }
                            c.push(g)
                        }
                        d = c.length;
                        v = [];
                        p = $("<ul></ul>");
                        for (a = 0; a < d; a++) v.push({
                            index: a + 1,
                            note: c[a].eventprompt,
                            lonlat: c[a].lng + "," + c[a].lat
                        }),
                            n = v[a].index + ". " + v[a].note,
                            p.append($("<li id='p_ul_" + v[a].index + "'></li>").text(n)).append("<div class='bm'></div>");
                        $("#pathListdiv").empty();
                        $("#pathListdiv").append(p)
                    }
                },
                startMark: function (a) {
                    n = a;
                    E.activate()
                },
                pathItemClicked: function (a) {
                    if (y) e.removeFeatures(y);
                    else {
                        y = new Ol2.Feature.Vector;
                        var d = Ol2.Util.extend({},
                            Ol2.Feature.Vector.style["default"]);
                        d.strokeColor = "#B318F3";
                        d.strokeOpacity = .6;
                        d.strokeWidth = 7;
                        y.style = d
                    }
                    d = a.target.id.replace("p_ul_", "");
                    d = parseInt(d);
                    a = v[d - 1].lonlat.split(",");
                    var c = parseFloat(a[0]),
                        f = parseFloat(a[1]);
                    d == v.length ? b.map.setCenter(new Ol2.LonLat(c, f)) : (d = v[d].lonlat.split(","), a = A.ClipSeg(a, d, z), y.geometry = A.makeLine(a), e.addFeatures(y), y && (b.map.zoomToExtent(y.geometry.getBounds()), b.map.zoomTo(b.map.zoom - 1), 4E3 > b.map.getScale() && b.map.zoomToScale(4509), b.map.setCenter(y.geometry.getCentroid())))
                },
                keyPressedHandler: function (a) {
                    var b = $(a.target).attr("mk"),
                        d = $(a.target).val().trim();
                    if ("" != d && b != d) {
                        var c = $(a.target).parent().attr("id"),
                            c = parseInt("startDiv" == c ? -2 : "endDiv" == c ? -3 : c.replace("waypt_", ""));
                        $(a.target).attr("mk", d);
                        $.get(Service.LS + "words=" + encodeURI(d), null,
                            function (b, e, f) {
                                if ("success" == e && (e = b.result.features)) {
                                    b = [];
                                    for (f = 0; f < e.length; f++) {
                                        var n = e[f].name,
                                            n = n.replace(d, "<b>" + d + "</b>"),
                                            n = "<span class='poi_tip_name'>" + n + "&nbsp;</span>",
                                            q = e[f].district_text ? e[f].district_text.replace(/(山东省|市辖区)|>/g, "") : "";
                                        "" != q && (q = q.replace(d, "<b>" + d + "</b>"), q = "<span class='poi_tip_district'>" + q + "</span>");
                                        b.push($("<div></div>").html(n + q).attr("onclick", "PathSearch.setWsposition(this," + c + "," + e[f].lng + "," + e[f].lat + ",'" + e[f].name + "')"))
                                    }
                                    b.push("<hr style='height:1px;border:none;border-top: 1px #ebebeb solid;'></hr><a id='poiSearch_suglistclose' title='关闭' href='javascript:void(0)' >关闭</a>");
                                    e = $(a.target).offset();
                                    $("#poiSearch_suglist").empty().append(b).show().css({
                                        left: e.left + "px",
                                        top: e.top + 28 + "px"
                                    })
                                }
                            },
                            "jsonp")
                    }
                },
                getRgc: function (a, b) {
                    var d = a.geometry,
                        c = [];
                    c.push(Service.RGC2);
                    c.push("type=11&point=");
                    c.push(d.x);
                    c.push(",");
                    c.push(d.y);
                    $.get(c.join(""), null,
                        function (d, c, e) {
                            "success" == c && (d = "ok" == d.status ? d.result.address || d.result.road_address : "自定义点", -2 == b ? $("#startDiv :text").val(d) : -3 == b ? $("#endDiv :text").val(d) : ($("#waypt_" + b + " :text").val(d), d = $("#waypt_" + b + " :button"), $(d[0]).attr("popupid", a.id), $(d[1]).attr("popupid", a.id)))
                        },
                        "jsonp")
                },
                refreshMarker: function () {
                    f.removeAllFeatures();
                    var a = [];
                    l && a.push(l);
                    c && a.push(c);
                    f.addFeatures(a);
                    for (var b = a = 0; b < q.length; b++) if (null != q[b].v) {
                        var d = Ol2.Util.extend({},
                            Ol2.Feature.Vector.style["default"]);
                        d.externalGraphic = "../Content/map/images/leftDiv/png/" + (a + 1) + "[1].png";
                        d.graphicWidth = 23;
                        d.graphicHeight = 25;
                        d.fillOpacity = 1;
                        d.cursor = "pointer";
                        q[b].v.style = d;
                        f.addFeatures(q[b].v);
                        a++
                    }
                },
                pathStartEdit: function () {
                    E.deactivate();
                    null == C ? (C = new Ol2.Control.ModifyFeature(e), C.createVertices = !0, k.addControl(C)) : (C.deactivate(), C.initialize(e));
                    p.activate();
                    k.resetLayersZIndex()
                },
                makeLine: function (a) {
                    for (var b = [], d = 0; d < a.length; d += 2) b.push(new Ol2.Geometry.Point(parseFloat(a[d]), parseFloat(a[d + 1])));
                    return new Ol2.Geometry.LineString(b)
                },
                indexOfLyr: function (a, b, d) {
                    a = k.getPixelFromLonLat(new Ol2.LonLat(a.x, a.y));
                    b = b.features;
                    var c = b.length;
                    switch (d) {
                        case 1:
                            for (d = 0; d < c; d++) {
                                var e = k.getPixelFromLonLat(new Ol2.LonLat(b[d].geometry.x, b[d].geometry.y));
                                if (a.x < e.x + 11.5 && a.x > e.x - 11.5 && a.y < e.y + 12.5 && a.y > e.y - 12.5) return d
                            }
                            break;
                        case 2:
                            for (d = 0; d < c; d++) if (e = k.getPixelFromLonLat(new Ol2.LonLat(b[d].geometry.x, b[d].geometry.y)), a.x < e.x + 6 + 24 && a.x > e.x + 6 && a.y < e.y + -25 + 20 && a.y > e.y + -25) return d
                    }
                    return -1
                },
                deletePopupById: function (a) {
                    for (var b = k.popups,
                        d = b.length - 1; 0 <= d; d--) if (b[d].id === a) {
                            k.removePopup(b[d]);
                            break
                        }
                },
                buildWayPtPopup: function (a, b, d) {
                    var c = "<div><label unselectable='on' class='lbl-other-area popup-labels' style='z-index:100;'><span class='popup-txt'></span><div class='popup-btns1'><img src='../Content/map/images/lineRemove.png' popupid='" + a + "' onclick='PathSearch.removeWaypoint(" + d + ",this)' class='celianClose'/></div></label></div>",
                        e = Ol2.Util.getRenderedDimensions(c, null, {});
                    e.h = 20;
                    e.w = 24;
                    a = new Ol2.Popup.Anchored(a, b, e, c, {
                        size: new Ol2.Size(15, 10),
                        offset: new Ol2.Pixel(6, -25)
                    },
                        !1, null);
                    a.calculateNewPx = function (a) {
                        return a.offset(this.anchor.offset)
                    };
                    a.minSize = e;
                    a.opacity = "1";
                    a.backgroundColor = null;
                    a.routeIndex = d;
                    a.routeFlag = 1;
                    return a
                },
                switchLayerZIndex: function (a, b) {
                    var d = a.getZIndex(),
                        c = b.getZIndex();
                    d < c && (a.setZIndex(c), b.setZIndex(d))
                },
                setDrawLayerDefaultStyle: function (a, b) {
                    a.styleMap.styles["default"].setDefaultStyle(b)
                },
                getCurrPtGeometryIndex: function (a, b) {
                    for (var d = -1,
                        c = a.length - 1; 0 <= c; c--) if (a[c].id === b.id) {
                            d = c;
                            break
                        }
                    return d
                },
                closeModify: function () {
                    null != C && (null != C.feature && C.unselectFeature(C.feature), C.deactivate())
                },
                mousemoveFunc: function (a) {
                    var b = $(".olMapViewport").offset();
                    a = new Ol2.Pixel(a.clientX - b.left, a.clientY - b.top);
                    a = k.getLonLatFromPixel(a);
                    a = new Ol2.Geometry.Point(a.lon, a.lat);
                    p.considerSnapping(a, a)
                }
            };
        return {
            init: function (c) {
                h || (k = c.map, b = c, $("#tab_gps_div").append("<div id='paramDiv' style='width: 100%;padding-top:10px;'><div id='p_type' class='route_radio'><span><input type='radio' name='p_schame' value='fast' />最快线路</span> <span><input type='radio' name='p_schame' value='short'checked />最短线路</span><span><input type='radio' name='p_schame' value='nohign'/>不走高速</span></div><div style='position: relative;padding-left:10px;'><div class='route_switch' title='调换起止点'><input onclick='PathSearch.switchDirection()'></input></div><div class='route_search_box'><p id='startDiv' class='route_input route_input_start'><img src='../Content/map/images/leftDiv/transparent.gif' title='请输入驾车起点'><input type='text' class='route_textInput' style='width:210px;'/><input type='button' title='绘制起点' class='route_draw route_draw_start' onclick='PathSearch.setStart()'/></p><p id='waypoints' style='display: none;padding: 0'></p><p id='endDiv' class='route_input route_input_end'><img src='../Content/map/images/leftDiv/transparent.gif' title='请输入驾车终点'><input type='text' class='route_textInput' style='width:210px;'/><input type='button' title='绘制终点' class='route_draw route_draw_end' onclick='PathSearch.setEnd()'/></p></div></div><div style='margin:10px 12px 0px 12px;padding-bottom:10px;'><a class='route_btn' onclick='PathSearch.doSearch()'><img style='background-position: -78px -86px;' src='../Content/map/images/leftDiv/transparent.gif'>查询线路</a><a class='route_btn' onclick='PathSearch.clearResult()'><img style='background-position: -94px -86px;' src='../Content/map/images/leftDiv/transparent.gif'>清除结果</a><a class='route_btn' style='width:95px;margin-right:0px;' onclick='PathSearch.addWaypoint()'><img style='background-position: -109px -86px;' src='../Content/map/images/leftDiv/transparent.gif'>添加途经点</a></div></div><div id='pathResult' style='position: relative;border:0;border-top:#e5e5e5 solid 1px;'><div id='distanceLabel' class='route_result_distance'></div><div id='pathListdiv' data-calc-height='100%-40' style='height: 450px;overflow-y: auto;'></div></div>"), t = new Ol2.StyleMap({
                    fillOpacity: 0,
                    strokeOpacity: 0,
                    strokeColor: "blue",
                    pointRadius: 3
                }), c = new Ol2.StyleMap({
                    fillOpacity: 0,
                    strokeOpacity: 0,
                    pointRadius: 15
                }), e = new Ol2.Layer.Vector("pathsearchLayer", {
                    isRoadSearch: 1,
                    styleMap: c,
                    rendererOptions: {
                        zIndexing: !1
                    }
                }), f = new Ol2.Layer.Vector("stationLayer", {
                    styleMap: t,
                    rendererOptions: {
                        zIndexing: !1
                    }
                }), r = new Ol2.Layer.Vector("pathDLayer", {
                    styleMap: t,
                    rendererOptions: {
                        zIndexing: !1
                    }
                }), d = new Ol2.Layer.Vector("snapPtLayer"), a = (a = Ol2.Util.getParameters(window.location.href).renderer) ? [a] : Ol2.Layer.Vector.prototype.renderers, k.addLayers([d, e, f]), k.addLayers([r]), $("#p_type :radio").click(function (a) {
                    PathSearch.doSearch()
                }), e.events.on({
                    vertexmodified: function (a) {
                        F = new Ol2.Feature.Vector(a.vertex)
                    },
                    featuremodified: function (a) {
                        f.styleMap.styles["default"].setDefaultStyle(t);
                        A.closeModify();
                        a = a.feature;
                        null != F.geometry && (F.geometry.id == a.geometry.components[0].id || F.geometry.id == a.geometry.components[a.geometry.components.length - 1].id ? PathSearch.doSearch() : PathSearch.addWaypoint(F), $("#pathroot_popup").attr("display", "block"))
                    }
                }), $("#pathListdiv").delegate("li", "click", A.pathItemClicked), $("#paramDiv").delegate(":text", "keyup", A.keyPressedHandler), h = !0)
            },
            setWsposition: function (a, b, d, c, e) {
                $("#poiSearch_suglist").slideUp(200);
                a = new Ol2.Geometry.Point(d, c);
                a = new Ol2.Feature.Vector(a); -2 == b ? (PathSearch.setStart(a, 1), $("#startDiv :text").val(e)) : -3 == b ? (PathSearch.setEnd(a, 1), $("#endDiv :text").val(e)) : (PathSearch.setWaypoint(b, a, 1), $("#waypt_" + b + " :text").val(e))
            },
            doSearch: function () {
                if (null != l && null !== c) {
                    var a = parseInt($("#paramDiv").css("height")),
                        b = parseInt($("#tab_gps_div").css("height"));
                    $("#pathResult").attr("data-calc-height", "100%-" + a).css("height", b - a + "px");
                    $(window).resize();
                    a = "";
                    u = [];
                    u.push(l);
                    if (0 < g) for (b = 0; b < g; b++) null != q[b].v && (a += q[b].v.geometry.x + "," + q[b].v.geometry.y + ";", u.push(q[b].v));
                    u.push(c);
                    b = {
                        start: l.geometry.x + "," + l.geometry.y,
                        end: c.geometry.x + "," + c.geometry.y,
                        type: 0,
                        highway: 1
                    };
                    "" != a && (b.waypoint = a.replace(/;$/, ""));
                    $("#tab_gps").hasClass("active") || $("#tab_gps").click();
                    A.requestData(b)
                }
            },
            initCtrl: function () {
                this.clearResult();
                E = new Ol2.Control.DrawFeature(f, Ol2.Handler.Point, {
                    handlerOptions: {
                        layerOptions: {
                            renderers: a,
                            styleMap: t
                        }
                    }
                });
                E.events.on({
                    featureadded: function (a, b) {
                        -2 == n ? PathSearch.addStart(a.feature) : -3 == n ? PathSearch.setEnd(a.feature) : 0 <= n ? (null != B && A.deletePopupById(B), PathSearch.setWaypoint(n, a.feature)) : (f.removeFeatures([a.feature]), f.redraw());
                        n = -1;
                        A.setDrawLayerDefaultStyle(f, t);
                        f.refresh()
                    }
                });
                k.addControl(E);
                G = new Ol2.Control.DragFeature(f, {
                    onComplete: function (a, b) {
                        try {
                            A.closeModify(),
                                p.deactivate()
                        } catch (L) { }
                        var d = A.getCurrPtGeometryIndex(f.features, a),
                            c = -1;
                        0 === d ? c = -2 : d === f.features.length - 1 ? c = -3 : 0 <= d && (c = d - 1);
                        A.getRgc(a, c);
                        PathSearch.doSearch();
                        k.resetLayersZIndex();
                        for (var d = new Ol2.LonLat(a.geometry.x, a.geometry.y), c = k.popups, e = a.id, n = 0, q = c.length; n < q; n++) if (e === c[n].id) {
                            q = c[n].routeIndex;
                            k.removePopup(c[n]);
                            d = A.buildWayPtPopup(e, d, q);
                            k.addPopup(d);
                            break
                        }
                        G.deactivate()
                    }
                });
                k.addControl(G);
                G.activate();
                p = new Ol2.Control.Snapping({
                    layer: f,
                    targets: [{
                        layer: e,
                        tolerance: 15
                    }],
                    eventListeners: {
                        snap: function (a) {
                            k.resetLayersZIndex();
                            A.switchLayerZIndex(e, f);
                            C.activate();
                            C.selectFeature(e.features[0]);
                            C.handlers.drag.dragging || (a = a.point, -1 != A.indexOfLyr(a, f, 1) ? (A.switchLayerZIndex(f, e), A.closeModify(), G.activate()) : -1 != A.indexOfLyr(a, f, 2) && (A.closeModify(), k.resetLayersZIndex()), 5 <= g ? A.closeModify() : (d.removeAllFeatures(), a = new Ol2.Feature.Vector(a.clone()), a.style = I, d.addFeatures([a]), d.redraw()))
                        },
                        unsnap: function (a) {
                            d.removeAllFeatures();
                            d.redraw();
                            A.closeModify();
                            A.switchLayerZIndex(f, e);
                            G.activate()
                        }
                    }
                });
                k.addControl(p);
                p.activate();
                k.events.on({
                    mousemove: A.mousemoveFunc
                })
            },
            addStart: function (a, b) {
                A.setDrawLayerDefaultStyle(f, I);
                if (null == a) A.startMark(-2);
                else {
                    f.removeFeatures(l);
                    var d = Ol2.Util.extend({},
                        Ol2.Feature.Vector.style["default"]);
                    d.externalGraphic = "../Content/map/images/path/start.png";
                    d.graphicWidth = 23;
                    d.graphicHeight = 25;
                    d.fillOpacity = 1;
                    d.cursor = "pointer";
                    a.style = d;
                    null == b ? (A.getRgc(a, -2), f.redraw()) : 1 == b ? f.addFeatures(a) : 2 == b ? (A.getRgc(a, -2), f.addFeatures(a)) : 3 == b && (null != a.attributes.name ? $("#startDiv :text").val(a.attributes.name) : A.getRgc(a, -2), f.addFeatures(a));
                    l = a;
                    PathSearch.doSearch()
                }
                f.redraw()
            },
            setStart: function (a, b) {
                null != E && null != G && null != p || PathSearch.initCtrl();
                E.activate();
                PathSearch.addStart(a, b)
            },
            addEnd: function (a, b) {
                A.setDrawLayerDefaultStyle(f, I);
                if (null == a) A.startMark(-3);
                else {
                    f.removeFeatures(c);
                    var d = Ol2.Util.extend({},
                        Ol2.Feature.Vector.style["default"]);
                    d.externalGraphic = "../Content/map/images/path/end.png";
                    d.graphicWidth = 23;
                    d.graphicHeight = 25;
                    d.fillOpacity = 1;
                    d.cursor = "pointer";
                    a.style = d;
                    null == b ? (A.getRgc(a, -3), f.redraw()) : 1 == b ? f.addFeatures(a) : 2 == b ? (A.getRgc(a, -3), f.addFeatures(a)) : 3 == b && (null != a.attributes.name ? $("#endDiv :text").val(a.attributes.name) : A.getRgc(a, -3), f.addFeatures(a));
                    c = a;
                    PathSearch.doSearch()
                }
            },
            setEnd: function (a, b) {
                null != E && null != G && null != p || PathSearch.initCtrl();
                E.activate();
                PathSearch.addEnd(a, b)
            },
            setWaypoint: function (a, b, d, c) {
                A.setDrawLayerDefaultStyle(f, I);
                if (null == b) null != c && (B = $(c).attr("popupId")),
                    A.startMark(a);
                else for (c = 0; c < q.length; c++) if (q[c].i == a) {
                    null != q[c].v && f.removeFeatures(q[c].v);
                    var e = Ol2.Util.extend({},
                        Ol2.Feature.Vector.style["default"]);
                    e.externalGraphic = "../Content/map/images/leftDiv/png/" + (c + 1) + "[1].png";
                    e.graphicWidth = 23;
                    e.graphicHeight = 25;
                    e.fillOpacity = 1;
                    e.cursor = "pointer";
                    b.style = e;
                    null == d ? (A.getRgc(b, a), f.redraw()) : 1 == d ? f.addFeatures(b) : 2 == d && (A.getRgc(b, a), f.addFeatures(b));
                    q[c].v = b;
                    a = A.buildWayPtPopup(b.id, new Ol2.LonLat(b.geometry.x, b.geometry.y), m - 1);
                    k.addPopup(a);
                    PathSearch.doSearch();
                    break
                }
            },
            addWaypoint: function (a) {
                null != E && null != G && null != p || PathSearch.initCtrl();
                E.activate();
                if (5 <= g) alert("途径点已添加到上限");
                else {
                    var b = null;
                    null != a && (b = a.id);
                    0 == g && $("#waypoints").css("display", "block");
                    b = $("<p class='route_input'></p>").attr("id", "waypt_" + m).html("<img src='../Content/map/images/leftDiv/transparent.gif' title='请输入驾车途经点'><input type='text' class='route_textInput' style='width: 190px;'/><input type='button'  class='route_draw route_draw_mid' title='绘制途经点' popupId='" + b + "' onclick='PathSearch.setWaypoint(" + m + ", null, null, this)'/><input type='button' class='route_draw route_draw_delete' title='删除' popupId='" + b + "' onclick='PathSearch.removeWaypoint(" + m + ", this)' />");
                    $("#waypoints").append(b);
                    q.push({
                        i: m,
                        v: null
                    });
                    m++;
                    g++;
                    null != a && PathSearch.setWaypoint(m - 1, a, 2)
                }
            },
            removeWaypoint: function (a, b) {
                A.closeModify();
                $("#waypt_" + a).remove();
                for (var d = 0; d < q.length; d++) if (q[d].i == a) {
                    d = q.splice(d, 1);
                    f.removeFeatures(d[0].v);
                    break
                }
                g--;
                0 == g && $("#waypoints").css("display", "none");
                A.refreshMarker();
                null != b && (d = $(b).attr("popupId"), A.deletePopupById(d));
                PathSearch.doSearch();
                k.resetLayersZIndex()
            },
            clearResult: function () {
                if (null != k && null != f && null != e) {
                    A.setDrawLayerDefaultStyle(f, t);
                    $("#waypoints").empty().hide();
                    $("#startDiv :text").val("");
                    $("#endDiv :text").val("");
                    m = g = 0;
                    q = [];
                    v = [];
                    n = -1;
                    $("#pathListdiv").empty();
                    null != e && e.removeAllFeatures();
                    null != f && f.removeAllFeatures();
                    null != d && d.removeAllFeatures();
                    null != r && r.removeAllFeatures();
                    $("#distanceLabel").text("");
                    $("#distanceLabel").css("display", "none");
                    c = l = null;
                    if (null != k.popups) for (var a = k.popups.length - 1; 0 <= a; a--) 1 === k.popups[a].routeFlag && k.removePopup(k.popups[a]);
                    null != E && E.deactivate();
                    null != C && (C.deactivate(), C = null);
                    null != p && (p.deactivate(), p = null);
                    null != G && (G.deactivate(), G = null);
                    k.resetLayersZIndex();
                    k.events.un({
                        mousemove: A.mousemoveFunc
                    })
                }
            },
            switchDirection: function () {
                if (null != l && null != c) {
                    var a = l.geometry;
                    l.geometry = c.geometry;
                    c.geometry = a;
                    var a = $("#startDiv :text"),
                        b = $("#endDiv :text"),
                        d = a.val();
                    a.val(b.val());
                    b.val(d);
                    if (1 < g) for (q.reverse(), a = $("#waypoints").children().toArray(), $("#waypoints").empty(), b = a.length - 1; 0 <= b; b--) $("#waypoints").append(a[b]);
                    A.refreshMarker();
                    PathSearch.doSearch()
                }
            }
        }
    }(),
    MeasureTool = function () {
        var l, c = {
            mPointLayer: new Ol2.Layer.Vector("mpoint"),
            mPolylineLayer: new Ol2.Layer.Vector("mpolyline"),
            mPolygonLayer: new Ol2.Layer.Vector("mpolygon")
        },
            m = null,
            g = null,
            h = [],
            k = void 0,
            b = void 0,
            a = void 0,
            e = void 0,
            f = !1,
            d = !1,
            r = null,
            t = null,
            n = null,
            w = 0,
            y = void 0,
            q = {
                closeModify: function () {
                    null != r && (null != r.feature && r.unselectFeature(r.feature), r.deactivate())
                },
                deletePopupById: function (a) {
                    for (var b = l.popups,
                        d = b.length - 1; 0 <= d; d--) if (b[d].id === a) {
                            l.removePopup(b[d]);
                            break
                        }
                },
                updatePopupStr: function (a, b) {
                    var d = $("#span_" + b.id);
                    1 > a ? 1 > 100 * a ? (d.html((1E6 * a).toFixed(0)), d.next().eq(0).html("平方米")) : (d.html((100 * a).toFixed(2)), d.next().eq(0).html("公顷")) : (d.html(a.toFixed(2)), d.next().eq(0).html("平方公里"))
                },
                convertValueByUnit: function (a, b) {
                    b = parseFloat(b);
                    "米" === a && (b /= 1E3);
                    return b
                },
                vertexModifiedFunc: function (a, d) {
                    var e = a.vertex;
                    k = e;
                    var f = new Ol2.LonLat(e.x, e.y),
                        q = c.mPointLayer.getFeatureBy("ptInMlineId", e.id);
                    n.handler.point.move(f);
                    q ? (b = 2, q.move(f), d ? modifyLineUpdatePopups(a.feature, e, f, 2) : modifyPolygonUpdatePopups(a.feature, e, f, 2)) : (b = 1, d ? modifyLineUpdatePopups(a.feature, e, f, 1) : modifyPolygonUpdatePopups(a.feature, e, f, 1))
                },
                featureModifiedFunc: function (d, n) {
                    if (1 === b) {
                        y && (l.removePopup(y), y = void 0);
                        var v = d.feature.id,
                            h = k.id,
                            w = new Ol2.Feature.Vector(k, {
                                ctype: "mlpoint"
                            });
                        w.measureFeatureId = v;
                        w.ptInMlineId = h;
                        w.pointType = 2;
                        c.mPointLayer.addFeatures([w]);
                        n ? (w.belongToType = 1, w = buildPopup(n, "popup_" + w.id, new Ol2.LonLat(k.x, k.y), a, m, 2)) : (w.belongToType = 2, w = f ? buildPopup(n, "popup_" + w.id, new Ol2.LonLat(k.x, k.y), e, g, 3) : buildPopup(n, "popup_" + w.id, new Ol2.LonLat(k.x, k.y), null, null, 2));
                        w.measureFeatureId = v;
                        w.ptInMlineId = h;
                        l.addPopup(w)
                    }
                    q.resetAllStatus(n)
                },
                afterModifiedFunc: function (a) {
                    q.resetAllStatus(a);
                    r.deactivate();
                    n.deactivate();
                    t.deactivate();
                    l.resetLayersZIndex()
                },
                resetAllStatus: function (d) {
                    b = k = void 0;
                    d ? (a = void 0, c.mPolylineLayer.redraw()) : (e = void 0, f = !1, c.mPolygonLayer.redraw());
                    c.mPointLayer.redraw()
                },
                measureFunc: function (a, b) {
                    w = 0;
                    y && (l.removePopup(y), y = void 0);
                    var d = a.measure,
                        e, f, n, q = a.units;
                    b ? (e = a.geometry, f = e.components.length, n = "km" == q ? d : d / 1E3, m = q = "公里") : (e = a.geometry.components[0], f = e.components.length - 1, n = "km" == q ? d : d / 1E6, g = q = "平方公里");
                    var v = e.components[f - 1],
                        d = new Ol2.Feature.Vector(e);
                    b ? (c.mPolylineLayer.addFeatures([d]), c.mPolylineLayer.redraw()) : (c.mPolygonLayer.addFeatures([d]), c.mPolygonLayer.redraw());
                    f === h.length + 1 && (f = new Ol2.Feature.Vector(v, {
                        ctype: "mlpoint"
                    }), c.mPointLayer.addFeatures([f]), c.mPointLayer.redraw(), h.push(f.id));
                    var k = h.length;
                    f = "popup_" + h[k - 1];
                    for (var u = l.popups,
                        t = 0; t < k; t++) {
                        var r = h[t],
                            D = c.mPointLayer.getFeatureById(r);
                        D.measureFeatureId = d.id;
                        D.ptInMlineId = e.components[t].id;
                        var H;
                        b ? (D.belongToType = 1, H = k - 1) : (D.belongToType = 2, H = k);
                        D.pointType = 0 === t ? 1 : t === H ? 3 : 2;
                        for (D = u.length - 1; 0 <= D; D--) u[D].id === "popup_" + r && (u[D].id === f ? l.removePopup(u[D]) : (u[D].measureFeatureId = d.id, u[D].ptInMlineId = e.components[t].id))
                    }
                    e = new Ol2.LonLat(v.x, v.y);
                    q = buildPopup(b, f, e, n, q, 3);
                    q.measureFeatureId = d.id;
                    l.addPopup(q);
                    h = [];
                    $(".celianClose").css("cursor", "pointer");
                    $(".celianEdit").css("cursor", "pointer");
                    $("div.olMap").css({
                        cursor: "default"
                    });
                    b ? l.getControl("measureLineControl").deactivate() : l.getControl("measurePolygonControl").deactivate();
                    l.resetLayersZIndex()
                },
                measurePartialFunc: function (a, b) {
                    var d = a.measure,
                        e, f = a.units;
                    b ? (e = a.geometry, d = "km" == f ? d : d / 1E3, f = "公里") : (e = a.geometry.components[0], d = "km" == f ? d : d / 1E6, f = "平方公里");
                    var n = e.components.length,
                        g;
                    g = b ? 2 : 3;
                    if (n != w + g) {
                        var v;
                        if (b) v = e.components[n - 1];
                        else {
                            if (4 > n) return;
                            v = e.components[n - 2]
                        }
                        e = new Ol2.LonLat(v.x, v.y);
                        y && (l.removePopup(y), y = void 0);
                        y = buildPopup(b, "popup_layer", e, d, f, 4);
                        l.addPopup(y)
                    } else {
                        if (n < g) return;
                        v = e.components[n - g];
                        e = new Ol2.LonLat(v.x, v.y);
                        g = 2;
                        2 === n && (g = 1);
                        n = new Ol2.Feature.Vector(v, {
                            ctype: "mlpoint"
                        });
                        c.mPointLayer.addFeatures([n]);
                        c.mPointLayer.redraw();
                        h.push(n.id);
                        f = buildPopup(b, "popup_" + n.id, e, d, f, g);
                        l.addPopup(f);
                        w++
                    }
                    q.setPointLayer2Top()
                },
                measureBtnClickFunc: function (a) {
                    $("#toolbag_div").css("display", "none");
                    null != r && (null != r.feature && r.unselectFeature(r.feature), r.deactivate());
                    var b = l.getControl("measureLineControl"),
                        d = l.getControl("measurePolygonControl");
                    a ? (d.deactivate(), b.activate()) : (b.deactivate(), d.activate());
                    $("div.olMap").css({
                        cursor: "url('../Content/map/images/Line.cur'),auto"
                    })
                },
                setPointLayer2Top: function () {
                    l.setLayerZIndex(c.mPointLayer, l.getNumLayers() + 1)
                },
                setMLayer2Top: function (a) {
                    l.setLayerZIndex(a, l.getNumLayers() + 1)
                },
                getPtFeatureByPopupId: function (a) {
                    return (a = a.substring(6).replace(/(^\s*)|(\s*$)/g, "")) ? c.mPointLayer.getFeatureById(a) : null
                },
                getMeasureFeatureByPtFeature: function (a, b) {
                    return b.getFeatureById(a.measureFeatureId)
                },
                getCurrPtGeometryIndex: function (a, b, d) {
                    var c = -1;
                    a = a.geometry.components;
                    var e = a.length;
                    2 === d && --e;
                    for (d = e - 1; 0 <= d; d--) if (a[d].id === b) {
                        c = d;
                        break
                    }
                    return c
                },
                getPtGeometry: function (a, b) {
                    return a.geometry.components[b]
                },
                getPopupByPtGeometry: function (a) {
                    var b = null;
                    a = "popup_" + c.mPointLayer.getFeatureBy("ptInMlineId", a.id).id;
                    for (var d = l.popups,
                        e = d.length - 1; 0 <= e; e--) if (d[e].id === a) {
                            b = d[e];
                            break
                        }
                    return b
                },
                getTwoPtDistance: function (a, b, d) {
                    a = new Ol2.Geometry.LineString([a, b]);
                    d = d.getLength(a, "km");
                    return parseFloat(d)
                },
                getGeometryArea: function (a, b) {
                    var d = Math.abs(b.getArea(a.geometry, "km"));
                    return parseFloat(d)
                },
                getAfterAllPopupsDistance: function (a, b, d, c) {
                    var e = q.getPopupByPtGeometry(d),
                        f = $("#span_" + e.id);
                    d = parseFloat(f.html());
                    "米" === f.next().eq(0).html() && (d /= 1E3);
                    d = c - d;
                    1 >= c ? (f.html(1E3 * parseFloat(c.toFixed(1))), f.next().eq(0).html("米")) : (f.html(c.toFixed(3)), f.next().eq(0).html("公里"));
                    q.updatePopupSize(e);
                    b += 2;
                    for (c = a.geometry.components.length; b < c; b++) {
                        var e = q.getPopupByPtGeometry(q.getPtGeometry(a, b)),
                            f = $("#span_" + e.id),
                            n = parseFloat(f.html());
                        "米" === f.next().eq(0).html() && (n /= 1E3);
                        n += d;
                        1 > n ? (f.html(1E3 * parseFloat(n.toFixed(1))), f.next().eq(0).html("米")) : (f.html(n.toFixed(3)), f.next().eq(0).html("公里"));
                        q.updatePopupSize(e)
                    }
                },
                getPopupSize: function (a) {
                    a = Ol2.Util.getRenderedDimensions(a, null, {});
                    a.h += 24;
                    a.w += 1;
                    return a
                },
                updatePopupSize: function (a) {
                    a.updateSize();
                    var b = a.size;
                    b.w += 1;
                    a.setSize(b)
                },
                getMeasurePopup: function (a, b, d, c) {
                    var e = q.getPopupSize(d);
                    e.h = $(d).height() + 24;
                    a = new Ol2.Popup.Anchored(a, b, e, d, {
                        size: new Ol2.Size(15, 10),
                        offset: new Ol2.Pixel(5, -25)
                    },
                        !1, null);
                    a.calculateNewPx = function (a) {
                        return a.offset(this.anchor.offset)
                    };
                    a.minSize = e;
                    a.opacity = "1";
                    a.backgroundColor = null;
                    a.pointType = c;
                    return a
                }
            };
        return {
            init: function (b, h) {
                if (!d) {
                    "object" == typeof b ? $(b).append("<li class='toolbagClass' id='btnMeasureLine'><span class='btnToolbar-cont1'><span class='btnToolbar-img'></span>测距</span></li><li class='toolbagClass' id='btnMeasurePolygon'><span class='btnToolbar-cont1'><span class='btnToolbar-img' style='background-position:-22px 0;'></span>测面</span></li>") : $("#" + b).append("<li class='toolbagClass' id='btnMeasureLine'><span class='btnToolbar-cont1'><span class='btnToolbar-img'></span>测距</span></li><li class='toolbagClass' id='btnMeasurePolygon'><span class='btnToolbar-cont1'><span class='btnToolbar-img' style='background-position:-22px 0;'></span>测面</span></li>");
                    l = h.map;
                    var w = new Ol2.Style;
                    w.addRules([new Ol2.Rule({
                        symbolizer: {
                            Point: {
                                pointRadius: 3,
                                fillColor: "red",
                                fillOpacity: 1,
                                strokeWidth: 2,
                                strokeOpacity: 1,
                                strokeColor: "#FF0000"
                            },
                            Line: {
                                strokeWidth: 3,
                                strokeOpacity: .5,
                                strokeColor: "red",
                                strokeDashstyle: "solid"
                            },
                            Polygon: {
                                strokeWidth: 3,
                                strokeOpacity: .5,
                                strokeColor: "red",
                                fillColor: "white",
                                fillOpacity: .3
                            }
                        }
                    })]);
                    var w = new Ol2.StyleMap({
                        "default": w,
                        select: w,
                        temporary: w,
                        "delete": w,
                        unselect: w
                    }),
                        v = Ol2.Util.getParameters(window.location.href).renderer,
                        v = v ? [v] : Ol2.Layer.Vector.prototype.renderers;
                    c.mPointLayer.styleMap = w;
                    c.mPolylineLayer.styleMap = w;
                    c.mPolygonLayer.styleMap = w;
                    l.addLayers([c.mPolygonLayer, c.mPolylineLayer, c.mPointLayer]);
                    c.mPolylineLayer.events.on({
                        vertexmodified: function (a) {
                            q.vertexModifiedFunc(a, 1)
                        },
                        featuremodified: function (a) {
                            q.featureModifiedFunc(a, 1)
                        },
                        afterfeaturemodified: function (a) {
                            q.afterModifiedFunc(1)
                        }
                    });
                    c.mPolygonLayer.events.on({
                        vertexmodified: function (a) {
                            q.vertexModifiedFunc(a, 0)
                        },
                        featuremodified: function (a) {
                            q.featureModifiedFunc(a, 0)
                        },
                        afterfeaturemodified: function (a) {
                            q.afterModifiedFunc(0)
                        }
                    });
                    var u = new Ol2.Control.Measure(Ol2.Handler.Path, {
                        persist: !0,
                        geodesic: !0,
                        immediate: !0,
                        handlerOptions: {
                            layerOptions: {
                                renderers: v,
                                styleMap: w
                            }
                        }
                    });
                    u.id = "measureLineControl";
                    u.events.on({
                        measure: function (a) {
                            q.measureFunc(a, 1)
                        },
                        measurepartial: function (a) {
                            q.measurePartialFunc(a, 1)
                        }
                    });
                    var C = new Ol2.Control.Measure(Ol2.Handler.Polygon, {
                        persist: !0,
                        geodesic: !0,
                        immediate: !0,
                        handlerOptions: {
                            layerOptions: {
                                renderers: v,
                                styleMap: w
                            }
                        }
                    });
                    C.id = "measurePolygonControl";
                    C.events.on({
                        measure: function (a) {
                            q.measureFunc(a, 0)
                        },
                        measurepartial: function (a) {
                            q.measurePartialFunc(a, 0)
                        }
                    });
                    l.addControl(u);
                    l.addControl(C);
                    $("#btnMeasureLine").click(function (a) {
                        q.measureBtnClickFunc(1)
                    });
                    $("#btnMeasurePolygon").click(function (a) {
                        q.measureBtnClickFunc(0)
                    });
                    startEdit = function (a) {
                        if (a = $(a).attr("popupid")) {
                            a = q.getPtFeatureByPopupId(a);
                            var b, d;
                            1 === a.belongToType ? (b = q.getMeasureFeatureByPtFeature(a, c.mPolylineLayer), d = c.mPolylineLayer) : 2 === a.belongToType && (b = q.getMeasureFeatureByPtFeature(a, c.mPolygonLayer), d = c.mPolygonLayer);
                            null == r ? (r = new Ol2.Control.ModifyFeature(d), r.createVertices = !0, l.addControl(r)) : (null != r.feature && r.unselectFeature(r.feature), r.deactivate(), r.initialize(d));
                            r.activate();
                            r.selectFeature(b);
                            l.resetLayersZIndex();
                            r.moveLayerToTop();
                            n = new Ol2.Control.DrawFeature(c.mPointLayer, Ol2.Handler.Point);
                            n.events.on({
                                featureadded: function (a) {
                                    c.mPointLayer.removeFeatures([a.feature]);
                                    c.mPointLayer.redraw()
                                }
                            });
                            l.addControl(n);
                            n.activate();
                            t = new Ol2.Control.Snapping({
                                layer: c.mPointLayer,
                                targets: [{
                                    layer: d,
                                    tolerance: 15
                                }],
                                eventListeners: {
                                    snap: function (a) {
                                        r.moveLayerToTop()
                                    },
                                    unsnap: function (a) { }
                                }
                            });
                            l.addControl(t);
                            t.activate()
                        }
                    };
                    buildPopup = function (a, b, d, c, e, f) {
                        a = a ? getLengthPopupElement(b, c, e, f) : getAreaPopupElement(b, c, e, f);
                        return q.getMeasurePopup(b, d, a, f)
                    };
                    getLengthPopupElement = function (a, b, d, c) {
                        var e = "";
                        0 != b && (1 > parseFloat(b) ? (d = "米", e = (1E3 * parseFloat(b)).toFixed(1)) : (d = "公里", e = parseFloat(b).toFixed(3)));
                        return 4 === c ? '<div style="height: 45px;width: 130px;overflow: hidden;" ><label unselectable="on" class="lbl-other popup-labels" style="z-index:10; "><span id="span_' + a + '" class="popup-txt">' + e + "</span><span class='popup-txt'>" + d + "</span></label> <div style='position:absolute;margin:20px 0 0 10px;background-color:#fff;color:gray;'>单击确定点,双击结束</div></div>" : 1 === c || 2 === c ? (1 === c ? (b = "</span><span class='popup-txt'>起点", d = "lbl-start") : (b = e + "</span><span class='popup-txt'>" + d, d = "lbl-other"), '<div><label unselectable="on" class="' + d + '  popup-labels" style="z-index:10;"><span id="span_' + a + '" class="popup-txt">' + b + '</span><div class="popup-btns1"><img src="../Content/map/images/lineRemove.png" popupid="' + a + '" onclick="deleteFeatureNode(this,1)"  class="celianClose"></div></label></div>') : '<div><label unselectable="on" class="lbl-end popup-labels"  style="z-index:100;"><span id="span_' + a + '" class="popup-txt">' + e + "</span><span class='popup-txt'>" + d + '</span><div class="popup-btns2"><img src="../Content/map/images/lineRemove.png" popupid="' + a + '" onclick="deleteFeatureNode(this,1)" class="celianClose"></div><div class="popup-btns2"><img src="../Content/map/images/lineClean.png" popupid="' + a + '" onclick="deleteMeasureLineOrAreaLayer(this,1)" class="celianClose"></div><div class="popup-btns2"><img src="../Content/map/images/lineEdit.png" popupid="' + a + '" onclick="startEdit(this)" class="celianEdit"></div></label></div>'
                    };
                    getAreaPopupElement = function (a, b, d, c) {
                        var e = "";
                        0 != b && (1 > parseFloat(b) ? 1 > 100 * parseFloat(b) ? (d = "平方米", e = (1E6 * parseFloat(b)).toFixed(0)) : (d = "公顷", e = (100 * parseFloat(b)).toFixed(2)) : (d = "平方公里", e = parseFloat(b).toFixed(2)));
                        return 4 === c ? '<div style="height: 20px;width: 130px;><label unselectable="on" class="lbl-other-area popup-labels" style="z-index:10;"><span id="span_' + a + '" class="popup-txt">' + e + "</span><span class='popup-txt'>" + d + "</span></label><div style='position:absolute;margin:22px 0 0 10px;background-color:#fff;color:gray;'>单击确定点,双击结束</div></div>" : 3 === c ? '<div><label unselectable="on" class="lbl-end popup-labels" style="z-index:100;"><span id="span_' + a + '" class="popup-txt">' + e + "</span><span class='popup-txt'>" + d + '</span><div class="popup-btns2"><img src="../Content/map/images/lineRemove.png" popupid="' + a + '" onclick="deleteFeatureNode(this,0)" class="celianClose"/></div><div class="popup-btns2"><img src="../Content/map/images/lineClean.png" popupid="' + a + '" onclick="deleteMeasureLineOrAreaLayer(this,0)" class="celianClose"/></div><div class="popup-btns2"><img src="../Content/map/images/lineEdit.png" popupid="' + a + '" onclick="startEdit(this)" class="celianEdit"/></div></label></div>' : '<div><label unselectable="on" class="lbl-other-area popup-labels" style="z-index:100;"><span class="popup-txt"></span><div class="popup-btns1"><img src="../Content/map/images/lineRemove.png" popupid="' + a + '" onclick="deleteFeatureNode(this,0)" class="celianClose"/></div></label></div>'
                    };
                    deleteLineNodeUpdatePopups = function (a, b) {
                        var d = a.geometry.components.length,
                            c = q.getCurrPtGeometryIndex(a, b.ptInMlineId, 1),
                            e;
                        if (c < d - 1) {
                            if (0 === c) d = q.getPtGeometry(a, 1),
                                e = q.getPopupByPtGeometry(d),
                                $("#span_" + e.id).html("").parent().removeClass("lbl-other").addClass("lbl-start").children().eq(1).html("起点"),
                                e.pointType = 1,
                                e = 0,
                                c = 1;
                            else {
                                d = q.getPtGeometry(a, c - 1);
                                e = q.getPopupByPtGeometry(d);
                                var f = $("#span_" + e.id);
                                e = f.html();
                                "" === e && (e = 0);
                                e = parseFloat(e);
                                f = f.next().eq(0).html();
                                e = q.convertValueByUnit(f, e)
                            }
                            f = q.getPtGeometry(a, c + 1);
                            d = q.getTwoPtDistance(d, f, u);
                            q.getAfterAllPopupsDistance(a, c, f, e + d)
                        } else c === d - 1 && (d = q.getPtGeometry(a, c - 1), d = q.getPopupByPtGeometry(d), e = $("#span_" + d.id), c = e.html(), e = e.next().eq(0).html(), c = q.convertValueByUnit(e, c), c = getLengthPopupElement(d.id, c, e, 3), e = q.getPopupSize(c), d.setContentHTML(c), d.pointType = 3, d.setSize(e))
                    };
                    modifyLineUpdatePopups = function (b, d, c, e) {
                        var f, n = b.geometry.components.length,
                            g = q.getCurrPtGeometryIndex(b, d.id, 1);
                        if (0 === g) {
                            if (e = q.getPopupByPtGeometry(d)) c = buildPopup(1, e.id, c, 0, null, e.pointType),
                                l.removePopup(e),
                                e.destroy(),
                                l.addPopup(c),
                                f = 0
                        } else {
                            f = q.getPtGeometry(b, g - 1);
                            var h = q.getPopupByPtGeometry(f),
                                k = $("#span_" + h.id),
                                h = k.html(),
                                k = k.next().eq(0).html();
                            "" === h && (h = 0);
                            h = parseFloat(h);
                            h = q.convertValueByUnit(k, h);
                            f = q.getTwoPtDistance(f, d, u);
                            f = h + f;
                            if (2 === e) {
                                if (e = q.getPopupByPtGeometry(d)) c = buildPopup(1, e.id, c, f, null, e.pointType),
                                    l.removePopup(e),
                                    e.destroy(),
                                    l.addPopup(c)
                            } else 1 === e && (a = f, y && (l.removePopup(y), y = void 0), y = buildPopup(1, "length_popup_layer", c, f, m, 4), l.addPopup(y))
                        }
                        g !== n - 1 && (n = q.getPtGeometry(b, g + 1), d = q.getTwoPtDistance(d, n, u), q.getAfterAllPopupsDistance(b, g, n, f + d))
                    };
                    modifyPolygonUpdatePopups = function (a, b, d, c) {
                        var n = q.getCurrPtGeometryIndex(a, b.id, 2),
                            g = a.geometry.components,
                            h = g.length,
                            w = q.getGeometryArea(a, C);
                        e = w;
                        n === h - 2 && 1 === c ? (f = !0, c = q.getPtGeometry(a, h - 3), c = q.getPopupByPtGeometry(c), n = getAreaPopupElement(c.id, null, null, 2), h = q.getPopupSize(n), c.setContentHTML(n), c.setSize(h), k = b, y && (l.removePopup(y), y = void 0), y = buildPopup(0, "area_popup_layer", d, w, null, 3), l.addPopup(y)) : (f = !1, a = q.getPopupByPtGeometry(g[h - 2]), q.updatePopupStr(w, a), q.updatePopupSize(a), 2 === c ? (n === h - 2 ? (b = a, c = b.pointType) : (b = q.getPopupByPtGeometry(b), c = 2), b && (d = buildPopup(0, b.id, d, w, null, c), l.removePopup(b), b.destroy(), l.addPopup(d))) : 1 === c && (k = b, y && (l.removePopup(y), y = void 0), y = buildPopup(0, "area_popup_layer", d, null, null, 2), l.addPopup(y)))
                    };
                    deleteFeatureNode = function (a, b) {
                        q.closeModify();
                        var d = $(a).attr("popupid");
                        if (d) {
                            var e = q.getPtFeatureByPopupId(d),
                                f = e.ptInMlineId,
                                n,
                                h,
                                k,
                                w = !1;
                            b ? (n = c.mPolylineLayer, h = 2) : (n = c.mPolygonLayer, h = 3);
                            var v = q.getMeasureFeatureByPtFeature(e, n),
                                l = v.geometry.components,
                                m,
                                y;
                            b ? m = l.length : (m = l.length - 1, y = v.geometry.components[m - 1]);
                            if (m === h) {
                                for (var u = 0; u < h; u++) if (k = c.mPointLayer.getFeatureBy("ptInMlineId", l[u].id)) q.deletePopupById("popup_" + k.id),
                                    c.mPointLayer.removeFeatures(k);
                                n.removeFeatures(v)
                            } else if (b) for (deleteLineNodeUpdatePopups(v, e), u = m - 1; 0 <= u; u--) {
                                if (l[u].id === f) {
                                    v.geometry.components.splice(u, 1);
                                    break
                                }
                            } else {
                                for (u = m; 0 <= u; u--) if (l[u].id === f) if (h = v.geometry.components, u === m) {
                                    var t = h[1].clone();
                                    t.id = h[1].id;
                                    h.splice(u, 1);
                                    h.splice(0, 1);
                                    h.splice(v.geometry.components.length, 0, t)
                                } else u === m - 1 && (k = v.geometry.components[u - 1], w = !0),
                                    v.geometry.components.splice(u, 1);
                                v = q.getGeometryArea(v, C);
                                w ? (k = q.getPopupByPtGeometry(k), w = getAreaPopupElement(k.id, v, g, 3), v = q.getPopupSize(w), k.setContentHTML(w), k.pointType = 3, k.setSize(v)) : (k = q.getPopupByPtGeometry(y), q.updatePopupStr(v, k), q.updatePopupSize(k))
                            }
                            c.mPointLayer.removeFeatures(e);
                            n.redraw();
                            q.deletePopupById(d)
                        }
                    };
                    deleteMeasureLineOrAreaLayer = function (a, b) {
                        q.closeModify();
                        var d = $(a).attr("popupid");
                        if (d) {
                            for (var d = q.getPtFeatureByPopupId(d), d = b ? q.getMeasureFeatureByPtFeature(d, c.mPolylineLayer) : q.getMeasureFeatureByPtFeature(d, c.mPolygonLayer), e = d.geometry.components, f = e.length - 1; 0 <= f; f--) {
                                var n = c.mPointLayer.getFeatureBy("ptInMlineId", e[f].id);
                                n && (q.deletePopupById("popup_" + n.id), c.mPointLayer.removeFeatures(n))
                            }
                            b ? c.mPolylineLayer.removeFeatures(d) : c.mPolygonLayer.removeFeatures(d)
                        }
                    };
                    d = !0
                }
            },
            clear: function () {
                q.closeModify();
                for (var a in c) c[a].removeAllFeatures()
            }
        }
    }(),
    MapSwitch = function () {
        function l() {
            g.map.events.unregister("click", g.map, c)
        }
        function c(c) {
            var h = g.map.getExtent(),
                h = h.left + "," + h.bottom + "," + h.right + "," + h.top,
                b = c.xy;
            b || (b = $(g.map.div).offset(), b = {
                x: c.clientX - b.left,
                y: c.clientY - b.top
            });
            var a = g.map.getLonLatFromPixel(b);
            c = '{"x":' + a.lon + ',"y":' + a.lat + "}";
            b = g.map.size;
            h = {
                imageDisplay: b.w + "," + b.h + ",96",
                sr: g.map.getProjection().split(":")[1],
                mapExtent: h,
                geometry: c,
                layers: "all:0",
                geometryType: "esriGeometryPoint",
                returnGeometry: !1,
                tolerance: 5,
                f: "json"
            };
            jQuery.support.cors = !0;

            //注释
            $.ajax({
                data: h,
                method: "POST",
                url: "proxy/proxy.ashx?http://124.128.48.217:6080/arcgis/rest/services/streetview/MapServer/identify",
                success: function (b) {
                    b = JSON.parse(b);
                    if (null != b.results && 0 < b.results.length) {
                        var c = a.lon,
                            d = a.lat;
                        setTimeout(function () {
                            window.open("http://58.56.168.30:10071/Panorama/PanoTest/getPanoUrl?lon=" + parseFloat(c) + "&lat=" + parseFloat(d) + "&returnUrl=http://www.sdmap.gov.cn")
                        },
                            1E3)
                    } else alert("未找到全景点,请在全景轨迹覆盖处点击进入全景！")
                },
                error: function (a, b, d) { }
            })
        }
        var m = !1,
            g;
        return {
            init: function (h, k) {
                m || (g = k, "object" == typeof h ? $(h).append("<div id='vec_' title='地图' class='active'>    地 图</div><div id='img_' title='影像'>    影 像</div><div id='img_year_div'> <div class='switch_zj'><input id='zjshow' type='checkbox' checked='checked'/><label>注记</label></div></div>") : $("#" + h).append("<div id='vec_' title='地图' class='active'>    地 图</div><div id='img_' title='影像'>    影 像</div><div id='img_year_div'> <div class='switch_zj'><input id='zjshow' type='checkbox' checked='checked'/><label>注记</label></div></div>"), $("#img_").click(function (b) {
                    l();
                    0 < g.map.getLayersByName("Layer_streetview").length && g.map.getLayersByName("Layer_streetview")[0].setVisibility(!1);
                    $(this).addClass("active");
                    $("#vec_").removeClass("active");
                    $("#streetview_").removeClass("active");
                    $("#img_year_div").show();
                    $(".olControlScaleLineTop").css({
                        border: "solid 2px white",
                        "border-top": "none",
                        color: "white"
                    });
                    $(".olControlScaleLineBottom").css({
                        border: "solid 2px white",
                        "border-bottom": "none",
                        color: "white"
                    });
                    $(".number_year").removeClass("active");
                    g.tileLayerManager.switchMap("img", Bzj)
                }), $("#vec_").click(function (b) {
                    l();
                    0 < g.map.getLayersByName("Layer_streetview").length && g.map.getLayersByName("Layer_streetview")[0].setVisibility(!1);
                    $("#img_year_div").hide();
                    $(this).addClass("active");
                    $("#img_").removeClass("active");
                    $("#streetview_").removeClass("active");
                    $(".olControlScaleLineTop").css({
                        border: "solid 2px black",
                        "border-top": "none",
                        color: "black"
                    });
                    $(".olControlScaleLineBottom").css({
                        border: "solid 2px black",
                        "border-bottom": "none",
                        color: "black"
                    });
                    g.tileLayerManager.switchMap("vec", !0)
                }), $("#img_").mouseenter(function (b) {
                    $(this).hasClass("active") && $("#img_year_div").show()
                }), $("#img_year_div").mouseleave(function (b) {
                    $("#img_year_div").hide()
                }), $("#zjshow").click(function (b) {
                    $(this)[0].checked ? (g.tileLayerManager.setVisibility("img_n", !0), Bzj = !0) : (g.tileLayerManager.setVisibility("img_n", !1), Bzj = !1)
                }), $("#streetview_").click(function (b) {
                    $("#img_year_div").hide();
                    $(this).addClass("active");
                    $("#vec_").removeClass("active");
                    $("#img_").removeClass("active");
                    0 < g.map.getLayersByName("Layer_streetview").length ? g.map.getLayersByName("Layer_streetview")[0].setVisibility(!0) : (b = {
                        LAYERS: [0],
                        TRANSPARENT: !0,
                        STYLES: "",
                        FORMAT: "image/png",
                        SRS: g.map.getProjection()
                    },
                        b = new Ol2.Layer.WMS("Layer_streetview", "http://124.128.48.217:6080/arcgis/services/streetview/MapServer/WmsServer", b, {
                            isBaseLayer: !1,
                            opacity: .7,
                            singleTile: !0
                        }), g.map.addLayer(b));
                    g.map.events.register("click", g.map, c)
                }), m = !0)
            }
        }
    }(),
    RegionSwitch2 = function () {
        function l(b) {
            if (10 > b) return 0;
            if (14 > b) return 1;
            if (19 > b) return 2
        }
        function c(b) {

            var a = sdmap.map.getExtent(),
                a = a.left + "," + a.bottom + "," + a.right + "," + a.top,
                e = sdmap.map.getCenter(),
                f = sdmap.map.size;
            //莒县硬编码
            a = "118.19210815412,35.159322738265,119.52008056622,36.237356185531";
            e.lon = "118.85609436017";
            e.lat = "35.698339461898";
            b = {
                imageDisplay: f.w + "," + f.h + ",96",
                sr: 4326,
                mapExtent: a,//地图范围
                geometry: '{"x":' + e.lon + ',"y":' + e.lat + "}",
                //layers: "all:" + l(sdmap.map.zoom),
                layers: "all:1",
                geometryType: "esriGeometryPoint",
                returnGeometry: !!b,
                tolerance: 0,
                f: "json"
            };

            $.ajax({
                url: "http://124.128.48.217:6080/arcgis/rest/services/sdxzj/MapServer/identify",
                data: b,
                dataType: "jsonp",
                type: "POST",
                success: function (a) {

                    if (a.results && 1 > a.results.length) $("#btnxinzhenglabel").text(""),
                        g.removeAllFeatures();
                    else {
                        //debugger;
                        var xa = a.results[1];
                        a = a.results[0];
                        $("#btnxinzhenglabel").text(a.attributes.名称);
                        var b = a.attributes.名称 + a.attributes.OBJECTID;
                        h != b && (h = b, c(!0));
                        if (a.geometry) {
                            //debugger;
                            a = a.geometry;
                            g.removeAllFeatures();
                            for (var b = [], d = 0; d < a.rings.length; d++) {
                                for (var e = [], f = 0; f < a.rings[d].length; f++) {
                                    var k = new Ol2.Geometry.Point(a.rings[d][f][0], a.rings[d][f][1]);
                                    e.push(k)
                                }
                                e = new Ol2.Geometry.LinearRing(e);
                                b.push(e)
                            }
                            a = new Ol2.Geometry.Polygon(b);
                            a = new Ol2.Feature.Vector(a);
                            g.addFeatures(a)
                        }

                        //乡镇
                        //var xb = xa.attributes.名称 + xa.attributes.OBJECTID;
                        //if (xa.geometry) {
                        //    xa = xa.geometry;
                        //    //g.removeAllFeatures();
                        //    for (var b = [], d = 0; d < xa.rings.length; d++) {
                        //        for (var e = [], f = 0; f < xa.rings[d].length; f++) {
                        //            var k = new Ol2.Geometry.Point(xa.rings[d][f][0], xa.rings[d][f][1]);
                        //            e.push(k)
                        //        }
                        //        e = new Ol2.Geometry.LinearRing(e);
                        //        b.push(e)
                        //    }
                        //    xa = new Ol2.Geometry.Polygon(b);
                        //    xa = new Ol2.Feature.Vector(xa);
                        //    g.addFeatures(xa)
                        //}
                    }
                },
                error: function () {
                    console.log("failed")
                }
            })
            //画出莒县各乡镇的网格

            b = {
                searchText: "371122",
                contains: false,
                searchFields: "",
                sr: "",
                layers: "all:1,2",
                layerDefs: "",
                returnGeometry: true,
                maxAllowableOffset: "",
                geometryPrecision: "",
                dynamicLayers: "",
                returnZ: false,
                returnM: false,
                gdbVersion: "",
                f: "json"
            };

            //注释
            $.ajax({
                url: "http://124.128.48.217:6080/arcgis/rest/services/sdxzj/MapServer/find",
                data: b,
                dataType: "jsonp",
                type: "POST",
                success: function (a) {
                    if (a.results && a.results.length > 1) {
                        g.removeAllFeatures();
                        $.each(a.results, function (i, value) {
                            if (this.geometry) {
                                //debugger;
                                if (this.attributes.名称 == "中楼镇") return true;//踢掉中楼镇
                                var item = this.geometry;
                                for (var b = [], d = 0; d < item.rings.length; d++) {
                                    for (var e = [], f = 0; f < item.rings[d].length; f++) {
                                        var k = new Ol2.Geometry.Point(item.rings[d][f][0], item.rings[d][f][1]);
                                        e.push(k)
                                    }
                                    e = new Ol2.Geometry.LinearRing(e);
                                    b.push(e)
                                }
                                item = new Ol2.Geometry.Polygon(b);
                                item = new Ol2.Feature.Vector(item);
                                g.addFeatures(item)
                            }
                        });
                    }
                },
                error: function () {
                    console.log("failed")
                }
            })
        }
        function m() {
            k && 8 < sdmap.map.zoom && 16 > sdmap.map.zoom && c(!1)
        }
        var g, h, k = !1;
        return {
            init: function (b) {
                sdmap = b;
                sdmap.map.events.on({
                    moveend: m
                });
                b = Ol2.Util.extend({},
                    Ol2.Feature.Vector.style["default"]);
                b.fillOpacity = .05;
                b.strokeColor = "blue";
                b.fillColor = "blue";
                b.strokeWidth = 2;
                b.strokeDashstyle = "dot";
                g = new Ol2.Layer.Vector("行政边界", {
                    style: b
                });
                sdmap.addLayer(g)
            },
            open: function () {
                k = !0;
                c(!0);
                $("#btnxinzhenglabel").show();
                RegionSwitch && RegionSwitch.clear()
            },
            close: function () {
                k = !1;
                g.removeAllFeatures();
                $("#btnxinzhenglabel").hide()
            }
        }
    }(),
    //显示
    RegionSwitch = function () {
        function l(a) {
            a = eval(a);
            for (var b = a.length,
                d = [], c = 0; c < b; c++) {
                var e = a[c];
                d.push("<tr shi='" + e[0] + "'>");
                d.push("<td  class='mayerTitle' ><a>" + e[0] + "</a></td>");
                for (var f = 1; f < e.length; f++) 0 == (f - 1) % 6 && 1 != f && d.push("</tr><tr shi='" + e[0] + "'><td  class='mayerTitle' ></td>"),
                    d.push("<td ><a href='javascript:void(0);'>" + e[f] + "</a></td>");
                d.push("</tr>")
            }
            $("#cityTable").html(d.join(""))
        }
        function c() {
            $("#dict_text").removeClass("active");
            $("#dictDiv").css("display", "none")
        }
        function m(a) {
            a = a || window.event;
            0 == $(a.target).closest("#dict").length && (c(), $(document).unbind("click", m))
        }
        function g() {
            n && h()
        }
        function h() {
            if (!w) {
                $("#dictInfo").css("display", "none");
                var a = f.map.getCenter(),
                    b = f.map.getScale();
                $.ajax({
                    dataType: "xml",
                    url: Service.CitySearch + "lon=" + a.lon + "&lat=" + a.lat + "&scale=" + b,
                    success: function (a) {
                        a = a.getElementsByTagName("string");
                        var b = a[0].firstChild.nodeValue,
                            d = b.split(",");
                        1 == d.length ? $("#dict_text").text(b) : 2 == d.length ? $("#dict_text").text(d[1]) : 3 == d.length ? $("#dict_text").text(d[1] + ">" + d[2]) : $("#dict_text").text(a[0].firstChild.nodeValue.replace(/,/g, ">"))
                    }
                })
            }
        }
        function k(c, e) {

            var n = e ? 2 : 1,
                n = Service.CityBound + "cityName=" + encodeURIComponent(c) + "&ways=" + n + "&countryName=" + encodeURIComponent(e) + "&provinceName=" + encodeURIComponent("山东省");
            $.ajax({
                dataType: "xml",
                url: n,
                success: function (n) {

                    var q = n.getElementsByTagName("Shape");
                    if (isIE = -1 != navigator.userAgent.indexOf("MSIE")) {
                        var h = n.getElementsByTagName("LinkName")[0].text,
                            g = n.getElementsByTagName("Description")[0].text;
                        n = n.getElementsByTagName("LinkURL")[0].text
                    } else h = $(n.getElementsByTagName("LinkName")).text(),
                        g = $(n.getElementsByTagName("Description")).text(),
                        n = $(n.getElementsByTagName("LinkURL")).text();
                    $("#dictInfoTitle").text(h);
                    $("#dictInfoText").text(g);
                    $("#linkId").attr("href", n);
                    q = q[0].childNodes[0].data;
                    "" != e ? $("#dict_text").text(c + ">" + e) : $("#dict_text").text(c);
                    b(q);
                    w = !0;
                    f.map.zoomToExtent(d.getDataExtent());
                    setTimeout(function () {
                        w = !1
                    },
                        500);
                    t = 1;
                    r = setInterval(a, 600);
                    y = setTimeout(function () {
                        d.removeAllFeatures()
                    },
                        1E4);
                    setTimeout(function () {
                        $("#dictInfo").click()
                    },
                        500);
                    setTimeout(function () {
                        $("#dictInfoClose").click()
                    },
                        3E3)
                }
            })
        }
        function b(a) {
            var b = "{rings:[";
            a = a.substring(a.indexOf("(") + 1, a.lastIndexOf(")")).replace(/(\({2})/g, "(");
            a = a.replace(/(\){2})/g, ")");
            a = a.replace(/\(/g, "[").replace(/\)/g, "]");
            a = a.replace(/([\d\.]+)\s([\d\.]+)/g, "[$1,$2]");
            b = eval("(" + (b + a + "]}") + ")");
            d.removeAllFeatures();
            a = [];
            for (var c = 0; c < b.rings.length; c++) {
                for (var e = [], f = 0; f < b.rings[c].length; f++) {
                    var n = new Ol2.Geometry.Point(b.rings[c][f][0], b.rings[c][f][1]);
                    e.push(n)
                }
                e = new Ol2.Geometry.LinearRing(e);
                e = new Ol2.Geometry.Polygon([e]);
                a[c] = new Ol2.Feature.Vector(e)
            }
            d.addFeatures(a);
            d.redraw()
        }
        function a() {
            if (1 == t) {
                for (var a = 0; a < d.features.length; a++) d.features[a].style.fillColor = "green",
                    d.features[a].style.fillOpacity = .6,
                    d.redraw(!0);
                t += 1
            } else if (2 == t) {
                for (a = 0; a < d.features.length; a++) d.features[a].style.fillColor = "blue",
                    d.features[a].style.fillOpacity = .6,
                    d.redraw(!0);
                t += 1
            } else if (3 == t) {
                for (a = 0; a < d.features.length; a++) d.features[a].style.fillColor = "green",
                    d.features[a].style.fillOpacity = .6,
                    d.redraw(!0);
                t += 1
            } else if (4 == t) {
                for (a = 0; a < d.features.length; a++) d.features[a].style.fillOpacity = 0,
                    d.redraw(!0);
                t += 1
            } else clearTimeout(r)
        }
        var e = !1,
            f, d, r, t, n = !0,
            w = !1,
            y;
        return {
            init: function (a, b) {
                if (!e) {
                    f = b;
                    "object" == typeof a ? $(a).append("<div id='dictInfo'title='点击查看详情'><div id='dictInfoDiv'><div id='dictInfoTitle'>山东省</div><div id='dictInfoText'></div><div id='dictInfoClose'></div><a id='linkId'target='_blank'style='color:blue;display: block;height: 40px;line-height: 40px;'>详情链接</a></div></div><div style='clear:both'></div><div id='dictDiv'><div id='dict_list_title'><a class='sheng'>山东省</a><div id='dict_close'></div></div><div id='dict_item'><table border='0' cellspacing='0' cellpadding='0' width='100%' id='cityTable'></table></div></div>") : $("#" + a).append("<div id='dictInfo'title='点击查看详情'><div id='dictInfoDiv'><div id='dictInfoTitle'>山东省</div><div id='dictInfoText'></div><div id='dictInfoClose'></div><a id='linkId'target='_blank'style='color:blue;margin-left: 250px;'>详情链接</a></div></div><div style='clear:both'></div><div id='dictDiv'><div id='dict_list_title'><a class='sheng'>山东省</a><div id='dict_close'></div></div><div id='dict_item'><table border='0' cellspacing='0' cellpadding='0' width='100%' id='cityTable'></table></div></div>");
                    f.map.events.on({
                        moveend: g,
                        click: function () {
                            c()
                        }
                    });
                    $.ajax({
                        url: "../Scripts/map/dat/cities.txt",
                        dataType: "text",
                        success: l,
                        error: function (a, b, d) {
                            console.log && console.log("request cities data failed ! " + b)
                        }
                    });
                    var n = Ol2.Util.extend({},
                        Ol2.Feature.Vector.style["default"]);
                    n.fillOpacity = 0;
                    n.strokeColor = "blue";
                    n.fillColor = "blue";
                    n.strokeWidth = 2;
                    n.strokeDashstyle = "dot";
                    d = new Ol2.Layer.Vector("行政定位", {
                        style: n
                    });
                    f.addLayer(d);
                    $("#dict_text").click(function () {
                        $(this).hasClass("active") ? c() : ($("#dictDiv").css("display", "block"), $(this).addClass("active"), $(document).bind("click", m))
                    });
                    $("#dict_close").click(function (a) {
                        c()
                    });
                    $(".sheng").click(function () {
                        $("#dictDiv").css("display", "none");
                        $("#dictInfoDiv").css("display", "none");
                        var a = new Ol2.LonLat(119, 36.4);
                        f.map.setCenter(a, 7)
                    });
                    $("#cityTable").on("click", "td",
                        function () {
                            "" != $(this).text() && ($("#dictDiv").css("display", "none"), $("#dictInfo").css("display", "block"), $("#dictInfoDiv").css("display", "none"), $(this).hasClass("mayerTitle") ? (k($(this).text(), ""), $("#dict_text").text($(this).text())) : k($(this).parent().attr("shi"), $(this).text()), $("#dict_text").removeClass("active"))
                        });
                    $("#dictInfoClose").click(function (a) {
                        $("#dictInfoDiv").animate({
                            height: 0
                        },
                            "slow",
                            function () {
                                $(this).css({
                                    display: "none",
                                    height: "auto"
                                })
                            })
                    });
                    $("#dictInfo").click(function (a) {
                        "block" == $("#dictInfoDiv").css("display") ? $("#dictInfoDiv").css("display", "none") : ($("#dictInfoDiv").css("height", "auto"), a = $("#dictInfoDiv").height(), $("#dictInfoDiv").css("display", "block"), $("#dictInfoDiv").css("height", "0px"), $("#dictInfoDiv").animate({
                            height: a
                        },
                            "slow",
                            function (a) { }))
                    });
                    e = !0
                }
            },
            clear: function () {
                d.removeAllFeatures();
                y && (clearTimeout(y), y = null)
            },
            setActive: function (a) {
                n = !!a
            },

        }
    }(),
    Clean = function () {
        var l = !1;
        return {
            init: function (c) {
                l || ($("#btnClear").click(function (c) {
                    $(".olPopup").css("display", "none");
                    $("#tab_search").click();
                    $("#returnBtn").click();
                    MeasureTool.clear();
                    RegionSwitch.clear();
                    $("#searchExtent").hide();
                    PathSearch && PathSearch.clearResult();
                    PoiInfoPop.clear();
                    Plotting.clear();
                    WidgetManger.reset()
                }), l = !0)
            }
        }
    }(),
    FullScreen = function () {
        var l = !1;
        return {
            init: function () {
                l || ($("#btnExtent").click(function (c) {
                    $("#left_hidden").hasClass("show") || $("#left_hidden").click();
                    var l;
                    c = $(window).height();
                    if ($(this).hasClass("extent")) {
                        $(this).removeClass("extent");
                        if (l = parent.document.getElementById("topDiv")) l.style.display = "block";
                        if (l = parent.document.getElementById("content")) l.style.top = "100px",
                            l.style.height = c - 100 + "px",
                            l.setAttribute("data-calc-height", "100%-100");
                        $("#left_center").css({
                            height: c + "px"
                        });
                        $(this).html("<span class='btnToolbar-cont'><span class='btnToolbar-img' style='background-position: -128px 0;'></span>全屏</span>");
                        $(this).css("width", "54px");
                        $("#left_hidden").click()
                    } else {
                        if (l = parent.document.getElementById("topDiv")) l.style.display = "none";
                        if (l = parent.document.getElementById("content")) l.style.top = "0",
                            l.style.height = c + 100 + "px",
                            l.setAttribute("data-calc-height", "100%-0"),
                            $("#left_center").css({
                                height: "100%"
                            }),
                            $(this).addClass("extent"),
                            $(this).css("width", "76px");
                        $(this).html("<span class='btnToolbar-cont'><span class='btnToolbar-img' style='background-position: -128px 0;'></span>退出全屏</span>")
                    }
                    setInterval(function () {
                        $(window).resize()
                    },
                        500);
                    sdMap.map.updateSize()
                }), l = !0)
            }
        }
    }(),
    PrintMapTool = function () {
        var l = null,
            c = !1;
        return {
            init: function (m, g) {
                c || ("object" == typeof m ? $(m).append("<li class='toolbagClass' id='btnPrintDiv'><span class='btnToolbar-cont1'><span class='btnToolbar-img' style='background-position: -60px 0;top:3px;width:20px;'></span>打印</span></li>") : $("#" + m).append("<li class='toolbagClass' id='btnPrintDiv'><span class='btnToolbar-cont1'><span class='btnToolbar-img' style='background-position: -60px 0;top:3px;width:20px;'></span>打印</span></li>"), l = g.map, $("#btnPrintDiv").click(function (c) {
                    $("#toolbag_div").css("display", "none");
                    var h = l.getSize().w,
                        b = l.getSize().h;
                    c = window.open("");
                    var a = document.getElementById("mapDiv").innerHTML,
                        e = parseInt(b) - 10,
                        h = "<link rel='stylesheet' type='text/css' href='third/jstree/themes/default/style.css' /><link href='Openlayers/theme/default/style.css' rel='stylesheet' type='text/css' /> <style type=\"text/css\">.olImageLoadError{background-color: pink; opacity: 0!important; filter: alpha(opacity=0)!important;}.print-container {margin: auto;width:" + h + "px;height:" + b + "px;top: 50px;position: relative;}.geoD {width: 100%;height: 24px;line-height: 24px;border-bottom: 3px solid #B2B2B2;font-size: 14px;margin-bottom: 6px;font-weight:bold;}.geoTitle {width: 300px;height: 20px;line-height: 20px;font-size: 14px;border:none;}",
                        h = h + "#mapDiv {position: relative;height:" + e + "px;margin-bottom: 15px;clear: both;}",
                        h = h + '#geoft {content: ".";height: 77px;display: block;overflow: hidden;clear: both;}',
                        h = h + ".printMap {margin-bottom: 20px;float: right;}",
                        h = h + ".printMap span {background-position: 0px 0px;cursor: pointer;margin-right: 0px;margin-top: 5px;display: inline-block;width: 69px;height: 29px;background-image: url(../Content/map/images/ToolBar/print.png);}",
                        h = h + "</style>";
                    foot = "</head><script type='text/javascript'src='third/util.min.js'></script><body><div class='print-container'><div class='geoD'>标题：<input class='geoTitle' value='请输入标题信息，点击输入''></input></div><div id='mapDiv' >" + a + "</div><div id='geoft'><div class='printMap'>";
                    foot += "<span id='printMap' onclick = 'printDiv()'></span>";
                    foot += "</div></div></div></body></html>";
                    c.document.write("<!DOCTYPE html><html><head><META HTTP-EQUIV='pragma' CONTENT='no-cache'><META HTTP-EQUIV='Cache-Control' CONTENT='no-cache, must-revalidate'><META HTTP-EQUIV='expires' CONTENT='Wed, 26 Feb 1997 08:21:57 GMT'><meta http-equiv='Content-Type' content='text/html; charset=utf-8' /><meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' /><meta name='apple-mobile-web-app-capable' content='yes' /><title>地图打印</title>" + h + "<script type = 'text/javascript'>\nfunction printDiv(){var divObj = document.getElementById('printMap');divObj.style.display = 'none';window.print();divObj.style.display = 'block';}</script>" + foot);
                    DynamicLoading.css("css.min/style.min.css", c);
                    c.document.close()
                }), c = !0)
            }
        }
    }(),
    CopyRightTool = function () {
        return {
            init: function (l) {
                l.map.events.on({
                    zoomend: function (c) {
                        c = c.object.getZoom();
                        7 > c ? $("#remark").text("审图号:GS(2017)508号(版权:国家测绘地理信息局)") : 14 > c ? $("#remark").text("审图号:GS(2017)508号(版权:国家测绘地理信息局) 鲁SG(2017)040号(版权:山东省国土资源厅)") : $("#remark").text("审图号:鲁SG(2017)040号(版权:山东省国土资源厅)")
                    }
                })
            }
        }
    }(),
    MapCorrect = function () {
        return {
            userCookie: function () {
                var l = "";
                if (g_userid) if (navigator.cookieEnabled) {
                    var c;
                    c = "jiucuo_loginid=" + (escape("t:1,id:'" + g_userid + "',n:'" + g_username + "'") + ";path=/;");
                    document.cookie = c
                } else l = encodeURI("?param=" + g_userid + "#" + g_username);
                return l
            },
            openCorrect: function (l) {
                0 == $("#correctPopFrame").length && $("body").append("<div id='correctPopFrame'><div style='filter:alpha(opacity:50);opacity:0.5;background:#000;width:100%;height:100%;position:absolute;left:0;top:0;z-index: 1100'></div><div id='correct_view' style='position:absolute; left: 50%;top: 20px;padding: 0;margin-left:-480px;width:962px;height:482px;background-color:white;z-index: 1101'><iframe width='100%' height='100%' frameborder='no' border='0' marginwidth='0' marginheight='0' scrolling='no' allowtransparency='yes'></iframe><div id='corrview_close' style='position: absolute;top:5px;right:5px;width:20px;height:20px; background-image: url(../Content/map/images/close.png);' onclick='MapCorrect.close()'></div></div></div>");
                $("#correctPopFrame").css("display", "block").find("iframe").attr("src", Service.CorrectDir + "popview.html?" + parseParam(l))
            },
            close: function () {
                $("#correctPopFrame").css("display", "none")
            }
        }
    }(),
    MapToolUI = function () {
        var l = !1;
        return {
            init: function (c) {
                if (!l) {
                    var m = $("#toolDiv");
                    //m.append("    <ul style='margin:3px 0'>        <li id='btnExtent' class='btnToolbar' style='margin-right: 20px;'><span class='btnToolbar-cont'><span class='btnToolbar-img' style='background-position: -128px 0;'></span>全屏</span></li>        <li id='btntool' class='btnToolbar'><span class='btnToolbar-cont'><span class='btnToolbar-img' style='background-position: -142px 0;'></span>工具</span>           <div id='toolbag_div' style='width: 60px; border: 1px solid #25abf3; background: #f4f9fd;display: none; color: #777777;margin-top:2px;'>               <ul></ul>        </li>        <li id='btnClear' class='btnToolbar'><span class='btnToolbar-cont'><span class='btnToolbar-img' style='background-position: -158px 0;'></span>清除</span></li>        <li id='btnExtentMap' class='btnToolbar'><span class='btnToolbar-cont'><span class='btnToolbar-img' style='background-position: -111px 0;'></span>全图</span></li>        <li id='btnImgCompare' class='btnToolbar'><span class='btnToolbar-cont'><span class='btnToolbar-img' style='background-position: -96px 0;'></span>对比</span></li>        <li id='dict'><div id='dict_text'>山东省</div></li>        <li id='vec_img'></li>        <li id='btnJiucuo' class='btnToolbar'><span class='btnToolbar-cont'><span class='btnToolbar-img' style='background-position: -78px 0;'></span>纠错</span></li>        <li id='btnxinzheng' class='btnToolbar' style='width:78px;'><span class='btnToolbar-cont' style='padding:0;'>开启行政区划</span><div id='btnxinzhenglabel'></div></li>        </ul>");
                    var g = m.find("#btntool ul");
                    MeasureTool.init(g, c);
                    FullScreen.init();
                    Clean.init(c);
                    Plotting.init(g, c);
                    PrintMapTool.init(g, c);
                    RegionSwitch.init(m.find("#dict"), c);
                    RegionSwitch2.init(c);
                    MapSwitch.init(m.find("#vec_img"), c);
                    CopyRightTool.init(c);
                    MapContrast.init(c);
                    m.find("#btntool").mouseenter(function () {
                        $("#toolbag_div").css("display", "block")
                    });
                    m.find("#btntool").mouseleave(function () {
                        $("#toolbag_div").css("display", "none")
                    });
                    $("#btnExtentMap").click(function () {
                        var h = new Ol2.LonLat(119, 36.4);
                        c.map.setCenter(h, 7)
                    });
                    $("#btnImgCompare").click(function () {
                        MapContrast.startContrast()
                    });
                    $("#btnJiucuo").click(function () {
                        var c = MapCorrect.userCookie();
                        window.open(Service.CorrectDir + "index.html" + c)
                    });
                    $("#btnxinzheng").click(function () {
                        var c = $(this).children("span");
                        "关闭网格显示" == c.text() ? (c.text("开启网格显示"), RegionSwitch2.close(), RegionSwitch.setActive(!1)) : (c.text("关闭网格显示"), RegionSwitch2.open(), RegionSwitch.setActive(!0))
                    });
                    l = !0
                }
            }
        }
    }(),
    ImgCluster = function () {
        function l(a) {
            p && p.popup && (popup.feature = void 0, sdMap.map.removePopup(p.popup), p.popup.destroy(), popup = p.popup = void 0, a && (u.eraseFeatures(p), I = !1))
        }
        function c(b) {
            $("GPS", b).each(function () {
                a = $("id", this).text();
                n = $("X", this).text();
                w = $("Y", this).text();
                e = $("savename", this).text().replace(/\.jpg$/i, ".png");
                f = d = $("savename", this).text();
                r = $("orgname", this).text();
                t = $("userid", this).text();
                $("model", this).text();
                $("datetime", this).text();
                F = new Ol2.LonLat(n, w);
                y.push(new Ol2.Feature.Vector(new Ol2.Geometry.Point(F.lon, F.lat), {
                    x: F.lon,
                    y: F.lat,
                    html: '<div style="font-size: 14px;width:400px;height:50px;position:relative;"><div style="position:absolute;left:5px;top:5px;color:#3b9cfe;font-weight:bold;">' + r + '</div><div class="picRemark" style="position:absolute;left:5px;top:25px;color:#666;"></div><a class="viewSrcImg" href="http://124.128.48.212:8100/picserver/Pic/srcpic/' + d + '" target="_blank"  sourceImg="http://124.128.48.212:8100/picserver/Pic/srcpic/' + d + '">查看原图</a></div><div class="mid-img-container"><img src="http://124.128.48.212:8100/picserver/Pic/midpic/' + f + '" title="' + r + '"/></div><div style="font-size: 12px;text-align: center;position:relative;height:50px;width:400px;"><div class="picUser" style="position:absolute;top:10px;left:5px;color:#666;"></div><div class="picUploadTime" style="position:absolute;top:30px;left:5px;color:#666;"></div></div>',
                    img: "http://124.128.48.212:8100/picserver/Pic/minipic/" + e,
                    name: r,
                    picID: a,
                    circlebg: "../Content/map/images/ImageCluster/circlebg.png",
                    userid: t,
                    id: "img_" + G
                }));
                G++
            })
        }
        function m() {
            q = g();
            v = h();
            z = new Ol2.Layer.Vector("unClusters", {
                styleMap: new Ol2.StyleMap(v)
            });
            var a = !1,
                b = !1,
                d = new Ol2.Strategy.Cluster;
            d.distance = 100;
            u = new Ol2.Layer.Vector("Clusters", {
                strategies: [d],
                styleMap: new Ol2.StyleMap(q),
                isCluster: 1,
                clusterOver: function (d) {
                    null != d.layer && "undefined" !== typeof d.layer.isCluster && (null != D && (sdMap.map.removePopup(D), D = null), null == d.cluster || null == d.cluster.length || 1 >= d.cluster.length || (b = !0, D = new Ol2.Popup.Anchored("popExpandCluster", new Ol2.LonLat(d.geometry.x, d.geometry.y), new Ol2.Size(24, 24), '<div class="expandCluster" title="单击散开"/>', {
                        size: new Ol2.Size(16, 16),
                        offset: new Ol2.Pixel(13, -37)
                    },
                        !1, null), D.calculateNewPx = function (a) {
                            return a.offset(this.anchor.offset)
                        },
                        D.setBackgroundColor("transparent"), D.cluster = d.cluster, sdMap.map.addPopup(D), $("#popExpandCluster_contentDiv").css("overflow", "visible"), $(".expandCluster").hover(function () {
                            a = !0
                        },
                            function () {
                                a = !1;
                                setTimeout(function () {
                                    a || b || sdMap.map.removePopup(D)
                                },
                                    200)
                            }).click(function () {
                                var a = D.cluster;
                                if (1 < a.length && 19 > sdMap.map.getZoom()) {
                                    for (var b = [], d = 0; d < a.length; d++) b.push(a[d].geometry);
                                    a = (new Ol2.Geometry.Collection(b)).getBounds();
                                    sdMap.map.zoomToExtent(a)
                                }
                            })))
                },
                clusterOut: function (d) {
                    b = !1;
                    setTimeout(function () {
                        a || b || null == D || sdMap.map.removePopup(D)
                    },
                        200)
                }
            });
            H.addLayer(u, !0);
            H.addLayer(z, !0);
            sdMap.map.events.register("zoomend", sdMap.map,
                function () {
                    if (sdMap.map.getZoom() > E) "undefined" != typeof popup && (I = !0);
                    else if (C && "undefined" != typeof popup) {
                        I = !0;
                        for (var a = u.features,
                            b = !1,
                            c = 0,
                            e = a.length,
                            f; c < e; c++) if (f = a[c], f.cluster[0].attributes.id == p.cluster[0].attributes.id) {
                                b = !0;
                                break
                            }
                        b || l(I)
                    }
                    E = sdMap.map.getZoom();
                    d.distance = 19 <= E ? 0 : 17 <= E && 19 > E ? 30 : 14 <= E ? 50 : 100;
                    C && (u.removeFeatures(u.features), u.addFeatures(y))
                });
            u.removeFeatures(u.features);
            u.addFeatures(y);
            u.events.on({
                featureselected: function (a) {
                    l();
                    p = a.feature;
                    a = new Ol2.LonLat(p.cluster[0].geometry.x, p.cluster[0].geometry.y);
                    popup = new Ol2.Popup.FramedCloud("featurePopup", a, new Ol2.Size(200, 200), p.cluster[0].data.html, null, !0,
                        function (a) {
                            this.feature.layer = u;
                            B.unselect(this.feature)
                        });
                    p.popup = popup;
                    popup.feature = p;
                    popup.size = new Ol2.Size(300, 300);
                    sdMap.map.addPopup(popup);
                    k(p.cluster[0].data.picID)
                },
                featureunselected: function (a) {
                    p = a.feature;
                    l(I)
                }
            });
            z.events.on({
                featureselected: function (a) {
                    l();
                    p = a.feature;
                    a = new Ol2.LonLat(p.geometry.x, p.geometry.y);
                    popup = new Ol2.Popup.FramedCloud("featurePopup", a, new Ol2.Size(200, 200), p.data.html, null, !0,
                        function (a) {
                            this.feature.layer = z;
                            B.unselect(this.feature)
                        });
                    p.popup = popup;
                    popup.feature = p;
                    popup.size = new Ol2.Size(300, 300);
                    sdMap.map.addPopup(popup);
                    k(p.data.picID)
                },
                featureunselected: function (a) {
                    p = a.feature;
                    l()
                }
            })
        }
        function g() {
            var a = new Ol2.Rule({
                filter: new Ol2.Filter.Comparison({
                    type: Ol2.Filter.Comparison.EQUAL_TO,
                    property: "count",
                    value: 1
                }),
                symbolizer: {
                    graphicWidth: 40,
                    graphicHeight: 40,
                    externalGraphic: "${img}"
                }
            }),
                b = new Ol2.Rule({
                    elseFilter: !0,
                    symbolizer: {
                        fontColor: "white",
                        fontSize: "13px",
                        fill: !0,
                        fillColor: "#ffcc66",
                        graphicWidth: 40,
                        graphicHeight: 40,
                        pointRadius: 10,
                        labelYOffset: 25,
                        labelXOffset: 25,
                        label: "${count}",
                        externalGraphic: "${img}",
                        backgroundGraphic: "${circlebg}",
                        backgroundXOffset: -4,
                        backgroundYOffset: -34,
                        labelSelect: !0
                    }
                });
            $.support.leadingWhitespace && (Browser.ie9above && (b.symbolizer.labelYOffset = 20), b.symbolizer.backgroundXOffset = -5, b.symbolizer.backgroundYOffset = -35);
            return new Ol2.Style({
                fontSize: "9pt",
                fontWeight: "bold"
            },
                {
                    rules: [a, b],
                    context: {
                        count: function (a) {
                            return a.attributes.count
                        },
                        img: function (a) {
                            return a.cluster[0].data.img
                        },
                        name: function (a) {
                            return a.cluster[0].data.name
                        },
                        circlebg: function (a) {
                            return a.cluster[0].data.circlebg
                        }
                    }
                })
        }
        function h() {
            return new Ol2.Style({},
                {
                    rules: [new Ol2.Rule({
                        symbolizer: {
                            fontColor: "white",
                            fontSize: "13px",
                            graphicWidth: 40,
                            graphicHeight: 40,
                            pointRadius: "10",
                            externalGraphic: "${img}"
                        }
                    })],
                    context: {
                        count: function (a) {
                            return a.attributes.count
                        },
                        img: function (a) {
                            return a.cluster ? a.cluster[0].data.img : a.data.img
                        },
                        name: function (a) {
                            return a.cluster ? a.cluster[0].data.name : a.data.name
                        }
                    }
                })
        }
        function k(a) {
            //注释
            $.ajax({
                type: "POST",
                url: "proxy/proxy.ashx?http://124.128.48.211:8100/picclient/PictureServlet?method=queryPicDetail",
                data: {
                    picid: a
                },
                success: function (a) {
                    a ? (a = eval("(" + a + ")"), $(".picRemark").text(a.remark), $(".picUser").text("上传用户：" + a.username), $(".picUploadTime").text("上传时间：" + a.uploadtime)) : alert("获取图片数据失败")
                }
            })
        }
        var b, a, e, f, d, r, t, n, w, y = [],
            q,
            v,
            u,
            z,
            F,
            B,
            C = !0,
            p,
            E = 7,
            G = 0,
            I = !1,
            A = !1,
            J = !1,
            D,
            H = null,
            K = null;
        return {
            init: function (a, b, d) {
                H = d;
                B = H.getSelectCtrl();
                A = !0
            },
            Show: function () {
                A && (J ? (l(), C ? (u.removeAllFeatures(), z.addFeatures(y), I = C = !1, $("#clusterSwitcher").text("打开聚类")) : (z.removeAllFeatures(), u.addFeatures(y), C = !0, $("#clusterSwitcher").text("取消聚类"), I = !1)) : K = $.ajax({
                    url: "proxy/proxy.ashx?http://124.128.48.211:8100/picclient/PictureServlet?method=queryAllPubXml",
                    type: "GET",
                    dataType: "xml",
                    success: function (a) {
                        a ? (b = a, c(b), m(), J = !0) : alert("获取图片数据失败")
                    },
                    error: function (a, b, d) {
                        console.log && console.log(b)
                    }
                }))
            },
            Hide: function () { },
            Dispose: function () {
                K && (K.abort(), K = null);
                H.removeLayer(u, !0);
                z.removeAllFeatures();
                y = [];
                J = A = !1
            },
            isInit: function () {
                return A
            }
        }
    };
function PollutionWidget() {
    function l() {
        var a;
        a = "water" == f ? "WasteWaterGis" : "air" == f ? "WasteAirGis" : "SewagePlantGis";
        k.removeAllFeatures();
        9 > h.map.zoom ? (r && r.abort(), 0 < t[0].length ? k.addFeatures(t[0]) : r = $.ajax({
            url: "proxy/pollution.ashx?" + $.param({
                _type: f,
                Method: "GetCompanyList_New",
                _t: Math.floor(Date.now() / 1E6)
            }),
            dataType: "json",
            success: function (a) {
                if (a) {
                    var b = [];
                    a = a.CityList;
                    for (var d = 0; d < a.length; d++) {
                        for (var c = parseFloat(a[d].Longitude), e = parseFloat(a[d].Latitude), f = a[d].ItemsInfos, n = 0, h = 0; h < f.length; h++) 0 < f[h].value && n++;
                        c = new Ol2.Feature.Vector(new Ol2.Geometry.Point(c, e));
                        e = Ol2.Util.extend({},
                            Ol2.Feature.Vector.style["default"]);
                        e.externalGraphic = "../Content/map/images/pollution/citylayer" + (0 < n ? "_cb" : "") + ".png";
                        e.graphicWidth = 60;
                        e.graphicHeight = 25;
                        e.fillOpacity = 1;
                        e.cursor = "pointer";
                        e.fontSize = "14px";
                        e.label = n + "/" + a[d].Count;
                        c.style = e;
                        c.attributes = {
                            cityCode: a[d].cityCode
                        };
                        b.push(c)
                    }
                    t[0] = b;
                    k.addFeatures(b)
                }
            },
            error: function (a, b) {
                console.log && console.log("污染数据请求" + b)
            }
        })) : (r && r.abort(), 0 < t[1].length ? k.addFeatures(t[1]) : r = $.ajax({
            url: "proxy/pollution.ashx?" + $.param({
                _type: "all",
                Method: "SelectSubList",
                stcode: 0,
                type: a,
                _t: Math.floor(Date.now() / 1E6)
            }),
            dataType: "json",
            success: function (a) {
                if (a) {
                    var b = [];
                    a = a.items;
                    for (var d = 0; d < a.length; d++) {
                        var c = parseFloat(a[d].longitude),
                            e = parseFloat(a[d].latitude),
                            c = new Ol2.Feature.Vector(new Ol2.Geometry.Point(c, e)),
                            e = Ol2.Util.extend({},
                                Ol2.Feature.Vector.style["default"]),
                            f;
                        switch (a[d].lever.value) {
                            case "0":
                                f = "green";
                                break;
                            case "-1":
                                f = "gray";
                                break;
                            case "-2":
                                f = "yellow";
                                break;
                            default:
                                f = "red"
                        }
                        e.externalGraphic = "../Content/map/images/pollution/" + f + ".png";
                        e.graphicWidth = 32;
                        e.graphicHeight = 60;
                        e.fillOpacity = 1;
                        e.cursor = "pointer";
                        "red" == f && (e.label = Math.round(parseFloat(a[d].lever.pollItemValue)) + "", e.labelYOffset = 13, e.fontSize = "14px");
                        c.style = e;
                        c.attributes = a[d];
                        b.push(c)
                    }
                    t[1] = b;
                    k.addFeatures(b)
                }
            },
            error: function (a, b) {
                console.log && console.log("污染数据请求" + b)
            }
        }))
    }
    function c(a) {
        null != h.widgetPop && h.removePopup(h.widgetPop);
        a = a.feature;
        var b = a.attributes;
        if (b.cityCode) h.map.setCenter(new Ol2.LonLat(a.geometry.x, a.geometry.y), 10);
        else {
            var d;
            $.ajax({
                url: "proxy/pollution.ashx?" + $.param({
                    _type: f,
                    Method: "GetRealTimeDataInfo_New",
                    SubID: b.subid,
                    _t: Math.floor(Date.now() / 1E6)
                }),
                async: !1,
                dataType: "text",
                success: function (a) {
                    d = a
                },
                error: function (a, b, d) { }
            });
            if (d) {
                d = JSON.parse(decryptByAES(token.pwd, d));
                for (var c = d.RealData,
                    n = '<div style="background-color: white;min-width: 330px;margin: 0 15px 10px 5px;">               <h  ><div class="popup_title"><span>' + c[0].StationName + '</span>--<span style="color: #805405;">【' + e[f].name + '】</span></div></h>    <div class="popup_content">                                                                            <table  cellpadding="0" cellspacing="0" border="0">                                                       <thead><tr><th>控制指标</th><th>监测值</th><th>标准</th><th>超标倍数</th></tr></thead>                  <tbody>                                                                                         ', g = 0; g < c.length; g++) n += "<tr><td>" + c[g].ItemName + "</td><td>" + (c[g].Val || "--") + "</td><td>" + (c[g].StandValue || "--") + "</td><td>" + (c[g].CBBS ? '<span style="color:red">' + c[g].CBBS + "</span>" : "--") + "</td></tr>";
                n += '         <tr><td colspan="4" style="font-size: 12px">单位：' + e[f].dw + '</td></tr>                </tbody>                                                                                               </table>                                                                                           <div><span class="item_title">生产状态:</span>' + d.Sczt.match(/>(\W*)<\/td><\/tr>.*$/)[1] + '</div>                                             <div ><span class="item_title">监测时间：</span>' + (c[0].DateTime || "--") + '</div>                                 </div><div class="pol_hist"><div subid="' + b.subid + '"></div></div>';
                h.widgetPop = new Ol2.Popup.FramedCloud("chicken", a.geometry.getBounds().getCenterLonLat(), null, n, null, !0,
                    function () {
                        h.removePopup(h.widgetPop);
                        h.unSelect()
                    });
                a.popup = h.widgetPop;
                h.addPopup(h.widgetPop);
                $(".pol_hist>div").click(function () {
                    var a = $(this).attr("subid");
                    m(a, c[0].StationName)
                })
            }
        }
    }
    function m(a, b) {
        0 == $("#pol_HistFrame").length && ($("body").append("<div id='pol_HistFrame'><div style='filter:alpha(opacity:50);opacity:0.3;background:#808080;width:100%;height:100%;position:absolute;left:0;top:0;z-index: 1100'></div><div id='pol_Hist_view' style='padding: 5px;border:1px solid #849DF9;border-radius: 5px;position:absolute; left: 50%;top: 50%;margin-top:-260px;padding: 0;margin-left:-480px;width:1000px;height:520px;background-color:white;z-index: 1101'><iframe style='margin: 2px 5px;border: 1px solid #C5C5C5;border-radius: 3px;' width='990' height='512' frameborder='no' border='0' marginwidth='0' marginheight='0' scrolling='no' allowtransparency='yes'></iframe><div style='position: absolute;position: absolute;top: 6px;font-size:14px;left: 12px;color: #1515EF;'>历史信息详情</div><div id='pol_Hist_close' style='position: absolute;top:6px;right:6px;width:20px;height:20px; background-image: url(../Content/map/images/close.png);' ></div></div></div>"), $("#pol_Hist_close").click(function () {
            $("#pol_HistFrame").hide()
        }));
        $("#pol_HistFrame").css("display", "block").find("iframe").attr("src", "http://58.56.98.78:8801/wryfb/WebGis/WasteWaterGis/History.aspx?SubId=" + a + "&SubName=" + escape(b))
    }
    function g(a) {
        if (9 > h.map.zoom) {
            if (0 == d) return
        } else if (1 == d) return;
        l()
    }
    if (null != PollutionWidget.unique) return PollutionWidget.unique;
    PollutionWidget.unique = this;
    var h = null,
        k = null,
        b = !1,
        a, e = {
            water: {
                name: "废水",
                dw: "排水量 m<sup>3</sup>/h，其他 mg/l"
            },
            air: {
                name: "废气",
                dw: "排气量 m<sup>3</sup>/h，其他 mg/m<sup>3</sup>"
            },
            fac: {
                name: "污水厂",
                dw: "排水量 m<sup>3</sup>/h，其他 mg/l"
            }
        },
        f,
        d,
        r = null,
        t = {
            0: [],
            1: []
        };
    return {
        init: function (d, e, f) {
            k = new Ol2.Layer.Vector("污染", {
                style: e,
                renderers: d
            });
            h = f;
            h.addLayer(k, !0);
            k.events.on({
                featureselected: c
            });
            a = $("<div></div>").attr("id", "lengend_poll").addClass("legenddiv").append("<img src='../Content/map/images/pollution/green.png'/>正常<img src='../Content/map/images/pollution/red.png'/>超标<img src='../Content/map/images/pollution/gray.png'/>停产<img src='../Content/map/images/pollution/yellow.png'/>故障");
            $("#" + h.map.div.id).append(a);
            b = !0
        },
        Show: function (a) {
            a = null == a ? "water" : a.split("_")[1];
            b && (a != f && (t = {
                0: [],
                1: []
            }), f = a, l(), h.map.events.register("zoomend", h.map, g))
        },
        Hide: function () {
            k.setVisibility(!1);
            null != h.widgetPop && h.removePopup(h.widgetPop);
            a.hide()
        },
        Dispose: function () {
            r && (r.abort(), r = null);
            h.removeLayer(k, !0);
            null != h.widgetPop && h.removePopup(h.widgetPop);
            h.map.events.unregister("zoomend", h.map, g);
            b = !1;
            d = f = null;
            a.remove();
            a = null;
            $("#pol_HistFrame").remove();
            k = null
        },
        isInit: function () {
            return b
        }
    }
}
//右侧浮动窗口-大网格
function WeatherWidget() {
    function l() {
        k = $.ajax({
            type: "GET",
            url: Service.RTServiceL + "type=weather&op=getweather&param={}&level=1&_t=" + Date.now(),
            dataType: "json",
            success: function (data) {
                if (data.success) {

                    b = data.result;
                    for (var a = [], c = 0; c < b.length; c++) {
                        var f = parseFloat(b[c].xPoint),
                            d = parseFloat(b[c].yPoint),
                            f = new Ol2.Feature.Vector(new Ol2.Geometry.Point(f, d)),
                            d = Ol2.Util.extend({},
                                Ol2.Feature.Vector.style["default"]);

                        var imgUrl = "";
                        if (b[c].level == 1) {
                            imgUrl = "../Content/map/images/Weather/b_1.png";
                        }
                        else if (b[c].level == 2) {
                            imgUrl = "../Content/map/images/Weather/b_2.png";
                        }
                        else if (b[c].level == 3) {
                            imgUrl = "../Content/map/images/Weather/b_3.png";
                        }

                        d.externalGraphic = imgUrl;
                        d.graphicWidth = 18;
                        d.graphicHeight = 18;
                        d.fillOpacity = 1;
                        d.cursor = "pointer";
                        f.style = d;
                        f.attributes = b[c];
                        a.push(f)
                    }
                    g.addFeatures(a)
                }
            },
            error: function (b, a) {
                console.log && console.log("综治中心数据请求" + a)
            }
        })
    }
    function c(b) {
        DynamicLoading.css("/Content/Map/css/map.css", c);

        null != m.widgetPop && m.removePopup(m.widgetPop);
        b = b.feature;
        for (var a = b.attributes, c = parseInt(a.HUMIDITY), f = Math.floor(c / 20), d = "<div class='weather_bk'>", h = 0; h < f; h++)
            d += "<div class='weather_ubk'></div>";
        c = (c - 20 * f) / 2;
        0 < c ? d += "<div class='weather_ubk ' style='width:" + c + "px;margin-right:0;'></div>" : 5 == f && (d = d.substr(0, d.length - 7) + " style='margin-right:0'></div>");
        d += "</div>";

        var c = b[d];
        var str = "";
        str += "<div class=\"container-fuild\" style=\"padding: 0 10px;\">";
        str += "<div class=\"tabcontroller\">";
        str += "<h4 style=\"float: left;margin:0;font-family: 宋体,Simsun;color: #ff9800;\">" + a.title + "</h4>";
        str += "<ul class=\"pull-right\"><li class=\"active\">网格介绍</li><li>人口统计</li><li>矛盾纠纷</li><li>特殊人群</li></ul>";
        str += "</div>";
        str += "<div id=\"myTabContent\" class=\"tab-content tabpanel\"  style=\"height: 300px;overflow: hidden;\">";
        str += "<div class=\"tab on\">";
        str += "   <div class=\"clearfix\">";
        str += "       <div class=\"pull-left\" style=\"width: 310px;height: auto;\">";
        str += "           <div class=\"swiper-container gallery-top\">";
        str += "               <div class=\"swiper-wrapper\">";
        str += "                   <div class=\"swiper-slide\" style=\"width: 310px;height: 300px;border: solid 1px #e1e1ee;background-image:url(../../.." + a.url + ")\"></div>";
        str += "               </div>";
        str += "           </div>";
        str += "       </div>";
        str += "       <div class=\"pull-right\" style=\"width: 300px;height: auto;\">";
        str += "           <ul class=\"list-group\" style=\"margin: 0;padding:0;\">";
        str += "               <li class=\"list-group-item clearfix\" style=\"margin: 0 0 0 12px;padding:0;\">";
        str += "                   <div style=\"margin: 0;padding:0;font-size: 16px; font-weight: 700;line-height: 32px;\">介绍：</div>";
        str += "                   <div style=\"height:268px;margin: 0;padding:0;font-size: 13px;line-height: 28px;overflow-y:auto;\">" + a.remarks + "</div>";
        str += "               </li>";
        str += "           </ul>";
        str += "       </div>";
        str += "   </div>";
        str += "</div>";
        str += "<div class=\"tab\">";
        str += "   <div id=\"personPercentage\" class=\"clearfix\" style=\"width:460px;height: 270px;margin: 0 auto;\">";
        str += "   </div>";
        str += "</div>";
        str += "<div class=\"tab\">";
        str += "   <div id=\"sumPerson\" class=\"clearfix\" style=\"width:460px;height: 270px;margin: 0 auto;\">";
        str += "   </div>";
        str += "</div>";
        str += "<div class=\"tab\">";
        str += "   <div id=\"sumSpecialPerson\" class=\"clearfix\" style=\"width:460px;height: 270px;margin: 0 auto;\">";
        str += "   </div>";
        str += "</div>";
        str += "</div>";
        str += "</div>";

        m.widgetPop = new Ol2.Popup.FramedCloud("chicken", b.geometry.getBounds().getCenterLonLat(), null, str, null, !0,
            function () {
                m.removePopup(m.widgetPop);
                m.unSelect()
            });
        b.popup = m.widgetPop;
        m.addPopup(m.widgetPop);

        $('.tabcontroller li').click(function () {
            var index = $(this).index();
            $(this).addClass('active').siblings().removeClass('active');
            $('.tabpanel .tab').eq(index).show().siblings().hide();
        });

        DynamicLoading.js("/libs/highcharts/highcharts.js", c);
        DynamicLoading.js("/libs/highcharts/exporting.js", c);
        DynamicLoading.js("/libs/highcharts/highcharts-zh_CN.js", c);

        //大网格人口统计
        $.ajax({
            type: "POST",
            url: "/Home/GetPersonPercentageByLevelLoadPage",
            contentType: "application/json",
            data: JSON.stringify({ id: a.id, level: a.level, parentId: 0 }),
            dataType: "json",
            success: function (res) {
                var data = eval(res.result);
                loadAreaChart("personPercentage", "人口占比", data);
            },
            error: function (a, b) {
                console.log && console.log("数据请求" + b)
            }
        });

        //大网格矛盾纠纷人数统计
        $.ajax({
            type: "POST",
            url: "/Home/GetSumPersonByLevelLoadPage",
            contentType: "application/json",
            data: JSON.stringify({ id: a.id, level: a.level, parentId: 0 }),
            dataType: "json",
            success: function (res) {
                var data = eval(res.result);
                loadColumnChart("sumPerson", "矛盾纠纷人数", data);
            },
            error: function (a, b) {
                console.log && console.log("数据请求" + b)
            }
        });

        //大网格特殊人群人数统计
        $.ajax({
            type: "POST",
            url: "/Home/GetSumSpecialPerson",
            contentType: "application/json",
            data: JSON.stringify({ id: a.id, level: a.level, parentId: 0 }),
            dataType: "json",
            success: function (res) {
                var data = eval(res.result);
                loadColumnChart("sumSpecialPerson", "特殊人群人数", data);
            },
            error: function (a, b) {
                console.log && console.log("数据请求" + b)
            }
        });

    }



    if (null != WeatherWidget.unique) return WeatherWidget.unique;
    WeatherWidget.unique = this;
    var m = null,
        g = null,
        h = !1,
        k = null;
    return {
        init: function (b, a, e) {
            g = new Ol2.Layer.Vector("天气", {
                style: a,
                renderers: b
            });
            m = e;
            m.addLayer(g, !0);
            g.events.on({
                featureselected: c
            });
            h = !0
        },
        Show: function () {
            h && l()
        },
        Hide: function () {
            g.setVisibility(!1);
            null != m.widgetPop && m.removePopup(m.widgetPop)
        },
        Dispose: function () {
            k && (k.abort(), k = null);
            m.removeLayer(g, !0);
            null != m.widgetPop && m.removePopup(m.widgetPop);
            h = !1;
            g = null
        },
        isInit: function () {
            return h
        }
    }
}
//右侧浮动窗口-中网格
function AreaWidget() {
    function l() {
        k = $.ajax({
            type: "GET",
            url: Service.RTServiceL + "type=weather&op=getweather&param={}&level=2&_t=" + Date.now(),
            dataType: "json",
            success: function (data) {
                if (data.success) {

                    b = data.result;
                    for (var a = [], c = 0; c < b.length; c++) {
                        var f = parseFloat(b[c].xPoint),
                            d = parseFloat(b[c].yPoint),
                            f = new Ol2.Feature.Vector(new Ol2.Geometry.Point(f, d)),
                            d = Ol2.Util.extend({},
                                Ol2.Feature.Vector.style["default"]);
                        d.externalGraphic = "../Content/map/images/Weather/b_2.png";
                        d.graphicWidth = 18;
                        d.graphicHeight = 18;
                        d.fillOpacity = 1;
                        d.cursor = "pointer";
                        f.style = d;
                        f.attributes = b[c];
                        a.push(f)
                    }
                    g.addFeatures(a)
                }
            },
            error: function (b, a) {
                console.log && console.log("数据请求" + a)
            }
        })
    }
    function c(b) {
        DynamicLoading.css("/Content/Map/css/map.css", c);

        null != m.widgetPop && m.removePopup(m.widgetPop);
        b = b.feature;
        for (var a = b.attributes, c = parseInt(a.HUMIDITY), f = Math.floor(c / 20), d = "<div class='weather_bk'>", h = 0; h < f; h++)
            d += "<div class='weather_ubk'></div>";
        c = (c - 20 * f) / 2;
        0 < c ? d += "<div class='weather_ubk ' style='width:" + c + "px;margin-right:0;'></div>" : 5 == f && (d = d.substr(0, d.length - 7) + " style='margin-right:0'></div>");
        d += "</div>";

        var c = b[d];

        var str = "";
        str += "<div class=\"container-fuild\" style=\"padding: 0 10px;\">";
        str += "<div class=\"tabcontroller\">";
        str += "<h4 style=\"float: left;margin:0;font-family: 宋体,Simsun;color: #ff9800;\">" + a.title + "</h4>";
        str += "<ul class=\"pull-right\"><li class=\"active\">网格介绍</li><li>人口统计</li><li>矛盾纠纷</li><li>特殊人群</li></ul>";
        str += "</div>";
        str += "<div id=\"myTabContent\" class=\"tab-content tabpanel\"  style=\"height: 300px;overflow: hidden;\">";
        str += "<div class=\"tab on\">";
        str += "   <div class=\"clearfix\">";
        str += "       <div class=\"pull-left\" style=\"width: 310px;height: auto;\">";
        str += "           <div class=\"swiper-container gallery-top\">";
        str += "               <div class=\"swiper-wrapper\">";
        str += "                   <div class=\"swiper-slide\" style=\"width: 310px;height: 300px;border: solid 1px #e1e1ee;background-image:url(../../.." + a.url + ")\"></div>";
        str += "               </div>";
        str += "           </div>";
        str += "       </div>";
        str += "       <div class=\"pull-right\" style=\"width: 300px;height: auto;\">";
        str += "           <ul class=\"list-group\" style=\"margin: 0;padding:0;\">";
        str += "               <li class=\"list-group-item clearfix\" style=\"margin: 0 0 0 12px;padding:0;\">";
        str += "                   <div style=\"margin: 0;padding:0;font-size: 16px; font-weight: 700;line-height: 32px;\">介绍：</div>";
        str += "                   <div style=\"height:268px;margin: 0;padding:0;font-size: 13px;line-height: 28px;overflow-y:auto;\">" + a.remarks + "</div>";
        str += "               </li>";
        str += "           </ul>";
        str += "       </div>";
        str += "   </div>";
        str += "</div>";
        str += "<div class=\"tab\">";
        str += "   <div id=\"container\" class=\"clearfix\" style=\"width:460px;height: 270px;margin: 0 auto;\">";
        str += "   </div>";
        str += "</div>";
        str += "<div class=\"tab\">";
        str += "   <div id=\"sumPerson\" class=\"clearfix\" style=\"width:460px;height: 270px;margin: 0 auto;\">";
        str += "   </div>";
        str += "</div>";
        str += "<div class=\"tab\">";
        str += "   <div id=\"sumSpecialPerson\" class=\"clearfix\" style=\"width:460px;height: 270px;margin: 0 auto;\">";
        str += "   </div>";
        str += "</div>";
        str += "</div>";
        str += "</div>";

        m.widgetPop = new Ol2.Popup.FramedCloud("chicken", b.geometry.getBounds().getCenterLonLat(), null, str, null, !0,
            function () {
                m.removePopup(m.widgetPop);
                m.unSelect()
            });
        b.popup = m.widgetPop;
        m.addPopup(m.widgetPop);

        $('.tabcontroller li').click(function () {
            var index = $(this).index();
            $(this).addClass('active').siblings().removeClass('active');
            $('.tabpanel .tab').eq(index).show().siblings().hide();
        });

        DynamicLoading.js("/libs/highcharts/highcharts.js", c);
        DynamicLoading.js("/libs/highcharts/exporting.js", c);
        DynamicLoading.js("/libs/highcharts/highcharts-zh_CN.js", c);

        //中网格人口统计
        $.ajax({
            type: "POST",
            url: "/Home/GetPersonPercentageByLevelLoadPage",
            contentType: "application/json",
            data: JSON.stringify({ id: a.id, level: a.level, parentId: a.parentId }),
            dataType: "json",
            success: function (res) {
                var data = eval(res.result);
                loadAreaChart("container", "人口占比", data);
            },
            error: function (a, b) {
                console.log && console.log("数据请求" + b)
            }
        });

        //中网格矛盾纠纷人数统计
        $.ajax({
            type: "POST",
            url: "/Home/GetSumPersonByLevelLoadPage",
            contentType: "application/json",
            data: JSON.stringify({ id: a.id, level: a.level, parentId: 0 }),
            dataType: "json",
            success: function (res) {
                var data = eval(res.result);
                loadColumnChart("sumPerson", "矛盾纠纷人数", data);
            },
            error: function (a, b) {
                console.log && console.log("数据请求" + b)
            }
        });

        //中网格特殊人群人数统计
        $.ajax({
            type: "POST",
            url: "/Home/GetSumSpecialPerson",
            contentType: "application/json",
            data: JSON.stringify({ id: a.id, level: a.level, parentId: 0 }),
            dataType: "json",
            success: function (res) {
                var data = eval(res.result);
                loadColumnChart("sumSpecialPerson", "特殊人群人数", data);
            },
            error: function (a, b) {
                console.log && console.log("数据请求" + b)
            }
        });

    }



    if (null != AreaWidget.unique) return AreaWidget.unique;
    AreaWidget.unique = this;
    var m = null,
        g = null,
        h = !1,
        k = null;
    return {
        init: function (b, a, e) {
            g = new Ol2.Layer.Vector("天气", {
                style: a,
                renderers: b
            });
            m = e;
            m.addLayer(g, !0);
            g.events.on({
                featureselected: c
            });
            h = !0
        },
        Show: function () {
            h && l()
        },
        Hide: function () {
            g.setVisibility(!1);
            null != m.widgetPop && m.removePopup(m.widgetPop)
        },
        Dispose: function () {
            k && (k.abort(), k = null);
            m.removeLayer(g, !0);
            null != m.widgetPop && m.removePopup(m.widgetPop);
            h = !1;
            g = null
        },
        isInit: function () {
            return h
        }
    }
}
//右侧浮动窗口-小网格
function VillageWidget() {
    function l() {
        k = $.ajax({
            type: "GET",
            url: Service.RTServiceL + "type=weather&op=getweather&param={}&level=3&_t=" + Date.now(),
            dataType: "json",
            success: function (data) {
                if (data.success) {

                    b = data.result;
                    for (var a = [], c = 0; c < b.length; c++) {
                        var f = parseFloat(b[c].xPoint),
                            d = parseFloat(b[c].yPoint),
                            f = new Ol2.Feature.Vector(new Ol2.Geometry.Point(f, d)),
                            d = Ol2.Util.extend({},
                                Ol2.Feature.Vector.style["default"]);
                        d.externalGraphic = "../Content/map/images/Weather/b_3.png";
                        d.graphicWidth = 18;
                        d.graphicHeight = 18;
                        d.fillOpacity = 1;
                        d.cursor = "pointer";
                        f.style = d;
                        f.attributes = b[c];
                        a.push(f)
                    }
                    g.addFeatures(a)
                }
            },
            error: function (b, a) {
                console.log && console.log("综治中心数据请求" + a)
            }
        })
    }
    function c(b) {
        DynamicLoading.css("/Content/Map/css/map.css", c);

        null != m.widgetPop && m.removePopup(m.widgetPop);
        b = b.feature;
        for (var a = b.attributes, c = parseInt(a.HUMIDITY), f = Math.floor(c / 20), d = "<div class='weather_bk'>", h = 0; h < f; h++)
            d += "<div class='weather_ubk'></div>";
        c = (c - 20 * f) / 2;
        0 < c ? d += "<div class='weather_ubk ' style='width:" + c + "px;margin-right:0;'></div>" : 5 == f && (d = d.substr(0, d.length - 7) + " style='margin-right:0'></div>");
        d += "</div>";

        var c = b[d];

        var str = "";
        str += "<div class=\"container-fuild\" style=\"padding: 0 10px;\">";
        str += "<div class=\"tabcontroller\">";
        str += "<h4 style=\"float: left;margin:0;font-family: 宋体,Simsun;color: #ff9800;\">" + a.title + "</h4>";
        str += "<ul class=\"pull-right\"><li class=\"active\">网格介绍</li><li>人口统计</li><li>矛盾纠纷</li><li>特殊人群</li></ul>";
        str += "</div>";
        str += "<div id=\"myTabContent\" class=\"tab-content tabpanel\"  style=\"height: 300px;overflow: hidden;\">";
        str += "<div class=\"tab on\">";
        str += "   <div class=\"clearfix\">";
        str += "       <div class=\"pull-left\" style=\"width: 310px;height: auto;\">";
        str += "           <div class=\"swiper-container gallery-top\">";
        str += "               <div class=\"swiper-wrapper\">";
        str += "                   <div class=\"swiper-slide\" style=\"width: 310px;height: 300px;border: solid 1px #e1e1ee;background-image:url(../../.." + a.url + ")\"></div>";
        str += "               </div>";
        str += "           </div>";
        str += "       </div>";
        str += "       <div class=\"pull-right\" style=\"width: 300px;height: auto;\">";
        str += "           <ul class=\"list-group\" style=\"margin: 0;padding:0;\">";
        str += "               <li class=\"list-group-item clearfix\" style=\"margin: 0 0 0 12px;padding:0;\">";
        str += "                   <div style=\"margin: 0;padding:0;font-size: 16px; font-weight: 700;line-height: 32px;\">介绍：</div>";
        str += "                   <div style=\"height:268px;margin: 0;padding:0;font-size: 13px;line-height: 28px;overflow-y:auto;\">" + a.remarks + "</div>";
        str += "               </li>";
        str += "           </ul>";
        str += "       </div>";
        str += "   </div>";
        str += "</div>";
        str += "<div class=\"tab\">";
        str += "   <div id=\"container\" class=\"clearfix\" style=\"width:460px;height: 270px;margin: 0 auto;\">";
        str += "   </div>";
        str += "</div>";
        str += "<div class=\"tab\">";
        str += "   <div id=\"sumPerson\" class=\"clearfix\" style=\"width:460px;height: 270px;margin: 0 auto;\">";
        str += "   </div>";
        str += "</div>";
        str += "<div class=\"tab\">";
        str += "   <div id=\"sumSpecialPerson\" class=\"clearfix\" style=\"width:460px;height: 270px;margin: 0 auto;\">";
        str += "   </div>";
        str += "</div>";
        str += "</div>";
        str += "</div>";

        m.widgetPop = new Ol2.Popup.FramedCloud("chicken", b.geometry.getBounds().getCenterLonLat(), null, str, null, !0,
            function () {
                m.removePopup(m.widgetPop);
                m.unSelect()
            });
        b.popup = m.widgetPop;
        m.addPopup(m.widgetPop);

        $('.tabcontroller li').click(function () {
            var index = $(this).index();
            $(this).addClass('active').siblings().removeClass('active');
            $('.tabpanel .tab').eq(index).show().siblings().hide();
        });

        DynamicLoading.js("/libs/highcharts/highcharts.js", c);
        DynamicLoading.js("/libs/highcharts/exporting.js", c);
        DynamicLoading.js("/libs/highcharts/highcharts-zh_CN.js", c);

        //小网格人口统计
        $.ajax({
            type: "POST",
            url: "/Home/GetPersonPercentageByLevelLoadPage",
            contentType: "application/json",
            data: JSON.stringify({ id: a.id, level: a.level, parentId: a.parentId }),
            dataType: "json",
            success: function (res) {
                var data = eval(res.result);
                loadAreaChart("container", "人口占比", data);
            },
            error: function (a, b) {
                console.log && console.log("数据请求" + b)
            }
        });

        //小网格矛盾纠纷人数统计
        $.ajax({
            type: "POST",
            url: "/Home/GetSumPersonByLevelLoadPage",
            contentType: "application/json",
            data: JSON.stringify({ id: a.id, level: a.level, parentId: 0 }),
            dataType: "json",
            success: function (res) {
                var data = eval(res.result);
                loadColumnChart("sumPerson", "矛盾纠纷人数", data);
            },
            error: function (a, b) {
                console.log && console.log("数据请求" + b)
            }
        });

        //小网格特殊人群人数统计
        $.ajax({
            type: "POST",
            url: "/Home/GetSumSpecialPerson",
            contentType: "application/json",
            data: JSON.stringify({ id: a.id, level: a.level, parentId: 0 }),
            dataType: "json",
            success: function (res) {
                var data = eval(res.result);
                loadColumnChart("sumSpecialPerson", "特殊人群人数", data);
            },
            error: function (a, b) {
                console.log && console.log("数据请求" + b)
            }
        });

    }



    if (null != VillageWidget.unique) return VillageWidget.unique;
    VillageWidget.unique = this;
    var m = null,
        g = null,
        h = !1,
        k = null;
    return {
        init: function (b, a, e) {
            g = new Ol2.Layer.Vector("天气", {
                style: a,
                renderers: b
            });
            m = e;
            m.addLayer(g, !0);
            g.events.on({
                featureselected: c
            });
            h = !0
        },
        Show: function () {
            h && l()
        },
        Hide: function () {
            g.setVisibility(!1);
            null != m.widgetPop && m.removePopup(m.widgetPop)
        },
        Dispose: function () {
            k && (k.abort(), k = null);
            m.removeLayer(g, !0);
            null != m.widgetPop && m.removePopup(m.widgetPop);
            h = !1;
            g = null
        },
        isInit: function () {
            return h
        }
    }
}

//右侧浮动窗口-矛盾纠纷
function RoadWiget() {
    function l(b) {
        null != b ? e[b] ? (k.removeFeatures(a[b]), e[b] = !1) : (k.addFeatures(a[b]), e[b] = !0) : (a = {
            road_kou: [],
            road_event: [],
            road_hu: []
        },
            h = $.ajax({
                url: Service.RTServiceL + "type=road&op=getinfo&param={type:'crk'}",
                dataType: "json",
                success: function (data) {
                    c(data.result)
                },
                error: function (a, b) {
                    console.log && console.log("矛盾纠纷数据请求" + b)
                }
            }))
    }
    function c(b) {
        if (k && "object" == typeof b) for (var d = 0; d < b.length; d++) {
            var c = b[d],
                e = parseFloat(c.xPoint),
                f = parseFloat(c.yPoint),
                e = new Ol2.Feature.Vector(new Ol2.Geometry.Point(e, f)),
                f = Ol2.Util.extend({},
                    Ol2.Feature.Vector.style["default"]);
            f.graphicWidth = 18;
            f.graphicHeight = 18;
            f.fillOpacity = 1;
            f.cursor = "pointer";
            e.attributes = c;
            //根据紧急程度设置颜色
            var graphicUrl = "crk20.png";
            switch (c.urgencyID) {
                case 1:
                    graphicUrl = "crk20.png";
                    break;
                case 2:
                    graphicUrl = "crk20_1.png";
                    break;
                case 3:
                    graphicUrl = "crk20_2.png";
                    break;
                default:
            }
            f.externalGraphic = "../Content/map/images/Road/" + graphicUrl;
            e.style = f;
            a.road_kou.push(e)
            k.addFeatures(e)
        }
    }
    function m(a) {
        null != g.widgetPop && g.removePopup(g.widgetPop);
        a = a.feature;
        var b = a.attributes;
        var content = b.eventDesc.replace(/<[^>]+>/g, "");//去掉所有的html标记

        var str = '<div class="container" style="padding: 0px 10px;width:728px;">' +
            '	<div class="page-header" style="margin-top:0;">' +
            '		<h4 style="margin-top:0;margin-bottom:0;font-family: 宋体,Simsun;color: #ff9800;">矛盾纠纷详情</h4>' +
            '	</div>' +
            '	<div class="row">' +
            '		<div class="col-sm-8">' +
            '			<div class="row" style="margin-left: 25px;">' +
            '				<div class="col-sm-12">' +
            '					<div class="row">' +
            '						<div class="col-sm-2 text-right"><strong>详细描述：</strong></div>' +
            '						<div class="col-sm-10">' +
            '							<p style="height: 64px;overflow-y: scroll;">' + content + '</p>' +
            '						</div>' +
            '					</div>' +
            '				</div>' +
            '				<div class="col-sm-6">' +
            '					<div class="row">' +
            '						<div class="col-sm-4 text-right"><strong>所属地区：</strong></div>' +
            '						<div class="col-sm-8">' +
            '							<p>' + b.townTitle + b.areaTitle + b.villageTitle + '</p>' +
            '						</div>' +
            '					</div>' +
            '				</div>' +
            '				<div class="col-sm-6">' +
            '					<div class="row">' +
            '						<div class="col-sm-4 text-right"><strong>上传人：</strong></div>' +
            '						<div class="col-sm-8">' +
            '							<p>' + b.uploadName + '</p>' +
            '						</div>' +
            '					</div>' +
            '				</div>' +
            '				<div class="col-sm-6">' +
            '					<div class="row">' +
            '						<div class="col-sm-4 text-right"><strong>纠纷来源：</strong></div>' +
            '						<div class="col-sm-8">' +
            '							<p>' + b.sourceTitle + '</p>' +
            '						</div>' +
            '					</div>' +
            '				</div>' +
            '				<div class="col-sm-6">' +
            '					<div class="row">' +
            '						<div class="col-sm-4 text-right"><strong>纠纷类型：</strong></div>' +
            '						<div class="col-sm-8">' +
            '							<p>' + b.disputeTypeTitle + '</p>' +
            '						</div>' +
            '					</div>' +
            '				</div>' +
            '				<div class="col-sm-6">' +
            '					<div class="row">' +
            '						<div class="col-sm-4 text-right"><strong>事发地点：</strong></div>' +
            '						<div class="col-sm-8">' +
            '							<p>' + b.eventAddress + '</p>' +
            '						</div>' +
            '					</div>' +
            '				</div>' +
            '				<div class="col-sm-6">' +
            '					<div class="row">' +
            '						<div class="col-sm-4 text-right"><strong>当事人：</strong></div>' +
            '						<div class="col-sm-8">' +
            '							<p>' + b.party + '</p>' +
            '						</div>' +
            '					</div>' +
            '				</div>' +
            '				<div class="col-sm-6">' +
            '					<div class="row">' +
            '						<div class="col-sm-4 text-right"><strong>涉及人数：</strong></div>' +
            '						<div class="col-sm-8">' +
            '							<p>' + b.involveNum + '</p>' +
            '						</div>' +
            '					</div>' +
            '				</div>' +
            '				<div class="col-sm-6">' +
            '					<div class="row">' +
            '						<div class="col-sm-4 text-right"><strong>登记时间：</strong></div>' +
            '						<div class="col-sm-8">' +
            '							<p>' + new Date(b.creationTime).Format("yyyy-MM-dd hh:mm:ss") + '</p>' +
            '						</div>' +
            '					</div>' +
            '				</div>' +
            '			</div>' +
            '		</div>' +
            '		<div class="col-sm-4">' +
            '			<div style="height: 195px;overflow: hidden;"><img src="../../Content/Map/images/emptyimage.png" style="width: 100%;height: auto;"></div>' +
            '		</div>' +
            '	</div>' +
            '	<div class="page-footer" style="margin-top:0;">' +
            '		<h4 style="margin-top:0;margin-bottom:0;font-family: 宋体,Simsun;color: #ff9800;">进度</h4>' +
            '	</div>' +
            '	<div class="progress">' +
            '		<div class="progress-bar bg-success">' +
            '			受理' +
            '		</div>' +
            '		<div class="progress-bar line bg-success">' +
            '		</div>' +
            '		<div class="progress-bar bg-danger">' +
            '			分流' +
            '		</div>' +
            '		<div class="progress-bar line">' +
            '		</div>' +
            '		<div class="progress-bar">' +
            '			调解' +
            '		</div>' +
            '		<div class="progress-bar line">' +
            '		</div>' +
            '		<div class="progress-bar">' +
            '			督办' +
            '		</div>' +
            '		<div class="progress-bar line">' +
            '		</div>' +
            '		<div class="progress-bar">' +
            '			回访' +
            '		</div>' +
            '		<div class="progress-bar line">' +
            '		</div>' +
            '		<div class="progress-bar">' +
            '			结束' +
            '		</div>' +
            '	</div>' +
            '</div>';


        //b.TOLLBOOTH

        g.widgetPop = new Ol2.Popup.FramedCloud("chicken", a.geometry.getBounds().getCenterLonLat(), null, str, null, !0,
            function () {
                null != g.widgetPop && g.removePopup(g.widgetPop)
            });
        a.popup = g.widgetPop;
        g.addPopup(g.widgetPop)
    }
    if (null != RoadWiget.unique) return RoadWiget.unique;
    RoadWiget.unique = this;
    var g = null,
        h = null,
        k = null,
        b = !1,
        a = null,
        e = {
            road_kou: !0,
            road_event: !0,
            road_hu: !0
        };
    return {
        init: function (a, d, c) {
            k = new Ol2.Layer.Vector("矛盾纠纷", {
                style: d,
                renderers: a
            });
            g = c;
            g.addLayer(k, !0);
            k.events.on({
                featureselected: m
            });
            b = !0
        },
        Show: function (a) {
            b && l(a)
        },
        Hide: function () {
            k.setVisibility(!1);
            null != g.widgetPop && g.removePopup(g.widgetPop)
        },
        Dispose: function () {
            h && (h.abort(), h = null);
            g.removeLayer(k, !0);
            null != g.widgetPop && g.removePopup(g.widgetPop);
            b = !1;
            a = {
                road_kou: [],
                road_event: [],
                road_hu: []
            };
            k = null
        },
        isInit: function () {
            return b
        }
    }
}
//一键报警弹出
function CallPoliceWidget() {
    function l() {
        k = $.ajax({
            type: "GET",
            url: "GetCallPolices",
            dataType: "json",
            success: function (data) {
                if (data.success) {

                    b = data.result;
                    for (var a = [], c = 0; c < b.length; c++) {
                        var f = parseFloat(b[c].xPoint),
                            d = parseFloat(b[c].yPoint),
                            f = new Ol2.Feature.Vector(new Ol2.Geometry.Point(f, d)),
                            d = Ol2.Util.extend({},
                                Ol2.Feature.Vector.style["default"]);
                        d.externalGraphic = "../Content/map/images/leftDiv/ball/r.png";
                        d.graphicWidth = 8;
                        d.graphicHeight = 8;
                        d.fillOpacity = 1;
                        d.cursor = "pointer";
                        f.style = d;
                        f.attributes = b[c];
                        a.push(f)
                    }
                    g.addFeatures(a)
                }
            },
            error: function (b, a) {
                console.log && console.log("一键报警数据请求" + a)
            }
        })
    }
    function c(b) {
        null != m.widgetPop && m.removePopup(m.widgetPop);
        b = b.feature;
        for (var a = b.attributes, c = parseInt(a.HUMIDITY), f = Math.floor(c / 20), d = "<div class='weather_bk'>", h = 0; h < f; h++)
            d += "<div class='weather_ubk'></div>";
        c = (c - 20 * f) / 2;
        0 < c ? d += "<div class='weather_ubk ' style='width:" + c + "px;margin-right:0;'></div>" : 5 == f && (d = d.substr(0, d.length - 7) + " style='margin-right:0'></div>");
        d += "</div>";

        var c = b[d];

        var str = "";
        str += "<div class=\"container-fuild\" style=\"padding: 0 10px;\">";
        str += "<div class=\"page-header\" style=\"margin-top:0;margin-bottom:10px;\">";
        str += "<h4 style=\"margin:0;font-family: 宋体,Simsun;color: #ff9800;\">" + a.title + "</h4>";
        str += "</div>";
        //str += "<ul id=\"myTab\" class=\"nav nav-tabs\" style=\"margin-bottom: 20px;\">";
        //str += "<li class=\"active\">";
        //str += "   <a href=\"#intro\" data-toggle=\"tab\">";
        //str += "      综治中心";
        //str += "  </a>";
        //str += "</li>";
        //str += "</ul>";
        str += "<div id=\"myTabContent\" class=\"tab-content\">";
        str += "<div class=\"tab-pane fade in active\" id=\"intro\">";
        str += "   <div class=\"clearfix\">";
        str += "       <div class=\"pull-left\" style=\"width: 250px;height: auto;\">";
        str += "           <div class=\"swiper-container gallery-top\">";
        str += "               <div class=\"swiper-wrapper\">";
        str += "                   <div class=\"swiper-slide\" style=\"width: 250px;height: 175px;border: solid 1px #e1e1ee;background-image:url(../../.." + a.url + ")\"></div>";
        str += "               </div>";
        //str += "               <div class=\"swiper-button-next swiper-button-white\" style=\"user-select: none;-ms-user-select: none;-moz-user-select: none;-webkit-user-select: none;\"></div>";
        //str += "               <div class=\"swiper-button-prev swiper-button-white\" style=\"user-select: none;-ms-user-select: none;-moz-user-select: none;-webkit-user-select: none;\"></div>";
        str += "           </div>";
        //str += "           <div class=\"swiper-container gallery-thumbs\">";
        //str += "               <div class=\"swiper-wrapper\">";
        //str += "                   <div class=\"swiper-slide\" style=\"height: 100px;background-image:url(../../../Temp/UpPicture/20171027/201710271430472.jpg)\"></div>";
        //str += "               </div>";
        //str += "           </div>";
        str += "       </div>";
        str += "       <div class=\"pull-right\" style=\"width: 360px;height: auto;\">";
        str += "           <ul class=\"list-group\" style=\"margin: 0;padding:0;\">";
        str += "               <li class=\"list-group-item clearfix\" style=\"margin: 0 0 0 12px;padding:0;\">";
        str += "                   <div class=\"pull-left\" style=\"width: 40px;margin: 0;padding:0;\">介绍：</div>";
        str += "                   <div class=\"pull-left\" style=\"width: 308px;height:172px;margin: 0;padding:0;overflow-y:auto;\">" + a.remarks + "</div>";
        str += "               </li>";
        str += "           </ul>";
        str += "       </div>";
        str += "   </div>";
        str += "</div>";
        str += "</div>";
        str += "</div>";

        m.widgetPop = new Ol2.Popup.FramedCloud("chicken", b.geometry.getBounds().getCenterLonLat(), null, str, null, !0,
            function () {
                m.removePopup(m.widgetPop);
                m.unSelect()
            });
        b.popup = m.widgetPop;
        m.addPopup(m.widgetPop)
    }



    if (null != CallPoliceWidget.unique) return CallPoliceWidget.unique;
    CallPoliceWidget.unique = this;
    var m = null,
        g = null,
        h = !1,
        k = null;
    return {
        init: function (b, a, e) {
            g = new Ol2.Layer.Vector("报警", {
                style: a,
                renderers: b
            });
            m = e;
            m.addLayer(g, !0);
            g.events.on({
                featureselected: c
            });
            h = !0
        },
        Show: function () {
            h && l()
        },
        Hide: function () {
            g.setVisibility(!1);
            null != m.widgetPop && m.removePopup(m.widgetPop)
        },
        Dispose: function () {
            k && (k.abort(), k = null);
            m.removeLayer(g, !0);
            null != m.widgetPop && m.removePopup(m.widgetPop);
            h = !1;
            g = null
        },
        isInit: function () {
            return h
        }
    }
}


function EnvironmentWidget() {
    function l() {
        null != a.widgetPop && a.removePopup(a.widgetPop);
        e.removeAllFeatures();
        var d = "type=enviro&op=getenvir&param={}";
        "station" != t && (d = "type=enviro&op=getCityInfo&param={}");
        k("莒县统计图");
        //f = $.ajax({
        //    type: "GET",
        //    url: Service.RTService + d,
        //    dataType: "jsonp",
        //    success: function (a) {
        //        if ("object" == typeof a) {
        //            var d = [];
        //            if ("station" == t) for (var f = 0; f < a.length; f++) {
        //                var n = a[f],
        //                    h = new Ol2.Feature.Vector(new Ol2.Geometry.Point(parseFloat(n.X), parseFloat(n.Y))),
        //                    g = Ol2.Util.extend({},
        //                        Ol2.Feature.Vector.style["default"]);
        //                g.externalGraphic = "../Content/map/images/environment/pm25_" + b[n.ST_LEVEL].i + ".png";
        //                g.graphicWidth = 25;
        //                g.graphicHeight = 25;
        //                g.fillOpacity = 1;
        //                g.cursor = "pointer";
        //                h.style = g;
        //                h.attributes = n;
        //                d.push(h)
        //            } else for (f = 0; f < a.length; f++) n = a[f],
        //                h = new Ol2.Feature.Vector(new Ol2.Geometry.Point(parseFloat(n.x), parseFloat(n.y))),
        //                g = Ol2.Util.extend({},
        //                    Ol2.Feature.Vector.style["default"]),
        //                g.externalGraphic = "../Content/map/images/environment/pm25_" + b[c(n.aqi)].i + ".png",
        //                g.graphicWidth = 25,
        //                g.graphicHeight = 25,
        //                g.fillOpacity = 1,
        //                g.cursor = "pointer",
        //                h.style = g,
        //                h.attributes = n,
        //                d.push(h);
        //            e.addFeatures(d)
        //        }
        //    },
        //    error: function (a, b) {
        //        console.log && console.log("AQI数据请求" + b)
        //    }
        //})
    }
    function c(a) {
        return 50 > a ? "Ⅰ" : 100 > a ? "Ⅱ" : 150 > a ? "Ⅲ" : 200 > a ? "Ⅳ" : 300 > a ? "Ⅴ" : "Ⅵ"
    }
    function m(a) {
        a = a.split(/[\/ :]/);
        return a[1] + "月" + a[2] + "日" + a[3] + "时"
    }
    function g(a) {
        if ("station" == t) a = ["<div style = 'width:345px;height:230px;font-size:12px;padding:0 5px;'><div style = 'position:absolute;top:0px;line-height:20px;color:#3b9cfe;'><b style='font-size:14px;'>", a.CITYNAME, " ", m(a.ST_DT), "</b></div><div style='padding-top:25px;'><div  style='float:left;line-height:1.5em;width:220px;display:inline-block;'><table><tr><td style=' font-weight: bold;color:#4d4d4d;'>空气质量指数AQI：</td><td>", a.ST_AQI, "</td></tr></table><table><tr><td style=' font-weight: bold;color:#4d4d4d;'>空气质量等级：</td><td>", a.ST_QUALITY, "(", a.ST_LEVEL, ")</td></tr></table><table><tr><td style=' font-weight: bold;color:#4d4d4d;'>首要污染物：</td><td>", a.ST_POL, "</td></tr></table><table><tr><td style=' font-weight: bold;width:65px;color:#4d4d4d;'>健康指引：</td><td style='width:120px;'>", b[a.ST_LEVEL].intro, "</td></tr></table></div><div style = 'display:inline-block;clear:right;'><img width='91px'height='102px' src='../Content/map/images/environment/", b[a.ST_LEVEL].i, ".png'></img><div style='width:120px;'>", b[a.ST_LEVEL].jianyi, "</div></div><div style='float:left;clear:both'><style>.paramindex{padding-left:25px;} .paramindex tr{font-size:14px;font-weight:bold;}.paramindex td{width:100px;}.paramindex span{color:#046abe;font-size:14px;padding-right:0px;}</style><table class='paramindex'><tbody><tr><td><span>PM2.5：</span>", Math.ceil(1E3 * parseFloat(a.ST_PM25)), "</td><td><span>PM10：</span>", Math.ceil(1E3 * parseFloat(a.ST_PM10)), "</td><td><span>SO2：</span>", Math.ceil(1E3 * parseFloat(a.ST_SO2)), "</td></tr><tr><td><span>NO2：</span>", Math.ceil(1E3 * parseFloat(a.ST_NO2)), "</td><td><span>CO：</span>", a.ST_CO, "</td><td><span>O3：</span>", Math.ceil(1E3 * parseFloat(a.ST_O3)), "</td></tr></tbody></table></div><div style='float:right;clear:both;padding-top:5px;'>单位:CO毫克/立方米，其它 微克/立方米</div></div>", '<div class="env_hist"><div name="' + a.CITYNAME + '"></div>', "</div>"].join("");
        else {
            var d = c(a.aqi);
            a = ["<div style = 'width:300px;height:200px;font-size:12px;padding:0 5px;'><div style = 'position:absolute;top:0px;line-height:20px;color:#3b9cfe;'><b style='font-size:14px;'>", a.name, " ", a.gettime.replace("T", " "), "</b></div><div style='padding-top:25px;'><div  style='float:left;line-height:1.5em;width:220px;display:inline-block;'><table><tr><td style=' font-weight: bold;color:#4d4d4d;'>空气质量指数AQI：</td><td>", a.aqi, "</td></tr></table><table><tr><td style=' font-weight: bold;color:#4d4d4d;'>空气质量等级：</td><td>", b[d].q, "(", d, ")</td></tr></table></div><div style='float:left;clear:both'><style>.paramindex{padding-left:6px;} .paramindex tr{font-size:14px;font-weight:bold;}.paramindex td{width:100px;height:30px;}.paramindex span{color:#046abe;font-size:14px;padding-right:0px;}</style><table class='paramindex'><tbody><tr><td><span>PM2.5：</span>", a.pm25, "</td><td><span>PM10：</span>", a.pm10, "</td><td><span>SO2：</span>", a.so2, "</td></tr><tr><td><span>NO2：</span>", a.no2, "</td><td><span>CO：</span>", a.co, "</td><td><span>O3：</span>", a.o3, "</td></tr></tbody></table></div><div style='clear:both;padding:6px;'>单位:CO毫克/立方米，其它 微克/立方米</div></div>", '<div class="env_hist"><div name="' + a.bm + '"></div>', "</div>"].join("")
        }
        return a
    }
    function h(b) {
        null != a.widgetPop && a.removePopup(a.widgetPop);
        b = b.feature;
        var d = g(b.attributes);
        a.widgetPop = new Ol2.Popup.FramedCloud("chicken", b.geometry.getBounds().getCenterLonLat(), null, d, null, !0,
            function () {
                null != a.widgetPop && (a.removePopup(a.widgetPop), a.unSelect())
            });
        a.addPopup(a.widgetPop);
        $(".env_hist>div").click(function () {
            var a = $(this).attr("name");
            k(a)
        })
    }
    function k(a) {
        0 == $("#env_HistFrame").length && ($("body").append("<div id='env_HistFrame'><div style='filter:alpha(opacity:50);opacity:0.3;background:#808080;width:100%;height:100%;position:absolute;left:0;top:0;z-index: 1100'></div><div id='env_Hist_view' style='border-radius: 5px;position:relative;margin:auto;top:5%; width:90%;height:90%;z-index: 1101'><iframe style='margin: 2px 5px;height:100%;width:100%;border: 1px solid #C5C5C5;border-radius: 3px;' width='100%' height='100%' frameborder='no' border='0' marginwidth='0' marginheight='0' scrolling='no' allowtransparency='yes'></iframe><div style='position: absolute;position: absolute;top: 6px;font-size:14px;left: 12px;color: #1515EF;'></div><div id='env_Hist_close' style='position: absolute;top:6px;right:6px;width:20px;height:20px; background-image: url(../Content/map/images/close.png);' ></div></div></div>"), $("#env_Hist_close").click(function () {
            $("#env_HistFrame").hide()
        }));
        //var b;
        //a && (b = "../page/envStatistic.html?name=" + encodeURIComponent(a), "city" == a ? b = "../page/envMonthStatistic.html" : "contrast" == a && (b = "EnvCityStatistic"));
        $("#env_HistFrame").css("display", "block").find("iframe").attr("src", "EnvCityStatistic");
    }
    if (null != EnvironmentWidget.unique) return EnvironmentWidget.unique;
    EnvironmentWidget.unique = this;
    var b = {
        "Ⅰ": {
            i: 1,
            q: "优",
            intro: "空气质量令人满意，基本无空气污染",
            jianyi: "非常适宜户外活动"
        },
        "Ⅱ": {
            i: 2,
            q: "良",
            intro: "空气质量可接受，但某些污染物可能对极少数异常，敏感人群健康有较弱影响",
            jianyi: "适宜户外活动或锻炼"
        },
        "Ⅲ": {
            i: 3,
            q: "轻度污染",
            intro: "易感人群症状有轻度加剧，健康人群出现刺激症状",
            jianyi: "减少户外锻炼"
        },
        "Ⅳ": {
            i: 4,
            q: "中度污染",
            intro: "进一步加剧易感人群症状，可能对健康人群心脏、呼吸系统有影响",
            jianyi: "停止户外锻炼，减少户外活动"
        },
        "Ⅴ": {
            i: 5,
            q: "重度污染",
            intro: "心脏病和肺病患者症状显著加剧，运动耐受力减低，健康人群普遍出现症状",
            jianyi: "不适宜户外活动，户外活动时应佩戴口罩"
        },
        "Ⅵ": {
            i: 6,
            q: "严重污染",
            intro: "健康人运动耐受力减低，有显著强烈症状，提前出现某些疾病",
            jianyi: "取消不必要的户外活动"
        },
        "--": {
            i: 7,
            q: "",
            intro: "无数据",
            jianyi: "设备故障"
        }
    },
        a = null,
        e = null,
        f = null,
        d = !1,
        r = null,
        t = "";
    return {
        init: function (b, c, f) {
            e = new Ol2.Layer.Vector("环境", {
                style: c,
                renderers: b
            });
            a = f;
            //r = $("<div></div>").attr("id", "lengend_envri").addClass("legenddiv").css("width", "300px").append("<img src='../Content/map/images/environment/aqi.png' width='300px' height='100px'/>");
            //$("#" + a.map.div.id).append(r);
            a.addLayer(e, !0);
            e.events.on({
                featureselected: h
            });
            d = !0
        },
        Show: function (a) {
            d && (a = null == a ? "station" : a.split("_")[1], "contrast" == a || "city" == a ? k(a) : (a != t && (t = a, l()), e.setVisibility(!0), $("#lengend_envri").show()))
        },
        Hide: function () {
            e.setVisibility(!1);
            $("#lengend_envri").hide();
            null != a.widgetPop && a.removePopup(a.widgetPop)
        },
        Dispose: function () {
            f && (f.abort(), f = null);
            a.removeLayer(e, !0);
            null != a.widgetPop && a.removePopup(a.widgetPop);
            d = !1;
            e = null;
            t = "";
            r.remove();
            r = null;
            $("#env_HistFrame").remove()
        },
        isInit: function () {
            return d
        }
    }
}
function WaterQuanlityWidget() {
    function l() {
        f = $.ajax({
            type: "GET",
            url: "proxy/proxy.ashx?http://www.sdmap.gov.cn:8081/testServ/waterservice.asmx/QueryTempa?parm=1",
            success: function (a) {
                f = $.ajax({
                    type: "GET",
                    url: "proxy/proxy.ashx?http://www.sdmap.gov.cn:8081/testServ/waterservice.asmx/QueryTempa?parm=2",
                    success: m,
                    error: function (a, b) {
                        console.log && console.log("面数据请求" + b)
                    }
                });
                m(a)
            },
            error: function (a, b) {
                console.log && console.log("线数据请求" + b)
            }
        })
    }
    function c(a) {
        t = a.xy
    }
    function m(a) {
        a = eval(a.documentElement.textContent || a.documentElement.text);
        for (var b = a.length,
            d = 0; d < b; d++) {
            var c = a[d].geom.split("@"),
                e = c.length;
            if (!(2 > e)) {
                for (var f = [], h = 1; h < e; h++) f.push(k(c[h]));
                a[d].geom = null;
                g(f, a[d])
            }
        }
    }
    function g(a, b) {
        if (e) {
            var d = a.length,
                c, f;
            if (!(1 > d)) {
                if ("1" == b.gtype) if (1 == d) d = new Ol2.Geometry.LineString(a[0]);
                else {
                    c = [];
                    for (f = 0; f < d; f++) c.push(new Ol2.Geometry.LineString(a[f]));
                    d = new Ol2.Geometry.MultiLineString(c)
                } else if (1 == d) d = new Ol2.Geometry.Polygon([new Ol2.Geometry.LinearRing(a[0])]);
                else {
                    c = [];
                    for (f = 0; f < d; f++) c.push(new Ol2.Geometry.Polygon([new Ol2.Geometry.LinearRing(a[f])]));
                    d = new Ol2.Geometry.MultiPolygon(c)
                }
                d = new Ol2.Feature.Vector(d);
                d.attributes = b;
                c = Ol2.Util.extend({},
                    Ol2.Feature.Vector.style["default"]);
                c.fillColor = h(b.water);
                c.fillOpacity = .5;
                c.strokeWidth = 2;
                c.strokeColor = h(b.water);
                c.cursor = "pointer";
                d.style = c;
                e.addFeatures(d)
            }
        }
    }
    function h(a) {
        switch (a) {
            case "I":
            case "II":
            case "III":
                a = "green";
                break;
            case "IV":
                a = "yellow";
                break;
            case "V":
                a = "coral";
                break;
            case "劣V":
                a = "red";
                break;
            default:
                a = "black"
        }
        return a
    }
    function k(a) {
        for (var b = a.length,
            d = [], c, e, f = 0; f < b; f += 10) e = a.substr(f, 5),
                c = a.substr(f + 5, 5),
                e = parseInt(e, 36) / 1E5,
                c = parseInt(c, 36) / 1E5,
                d.push(new Ol2.Geometry.Point(e, c));
        return d
    }
    function b(b) {
        var d = a.map.getLonLatFromViewPortPx(t);
        null != a.widgetPop && a.removePopup(a.widgetPop);
        var c = b.attributes,
            e = ["<div style='padding:0 5px;min-width:130px;'><div style = 'position:relative; margin-bottom:10px;color:#3b9cfe;'><b>主要河流水质状况</b></div> <div style = 'line-height:1.5em;'>创建日期："];
        e.push(c.year + "-" + c.month);
        e.push("<br>流域名称：");
        e.push(c.basin);
        e.push("<br>河流名称：");
        e.push(c.river);
        e.push("<br>断面名称：");
        e.push(c.section);
        e.push("<br>控制水域：");
        e.push(c.city);
        e.push("<br>水质类别：");
        e.push(c.water);
        e.push("<br>常见鱼类：<img src='../Content/map/images/water/fish1.png' width='30px' height='30px'/></div></div>");
        a.widgetPop = new Ol2.Popup.FramedCloud("chicken", d, null, e.join(""), null, !0,
            function () {
                a.removePopup(a.widgetPop);
                a.unSelect()
            });
        b.popup = a.widgetPop;
        a.addPopup(a.widgetPop)
    }
    if (null != WaterQuanlityWidget.unique) return WaterQuanlityWidget.unique;
    WaterQuanlityWidget.unique = this;
    var a = null,
        e = null,
        f = null,
        d = !1,
        r = null,
        t = null;
    return {
        init: function (f, h, g) {
            e = new Ol2.Layer.Vector("水质", {
                style: h,
                renderers: f
            });
            a = g;
            r = $("<div></div>").attr("id", "lengend_water").addClass("legenddiv").css("width", "239px").append("<img src='../Content/map/images/water/waterlegend.png' width='239px' height='50px'/>");
            $("#" + a.map.div.id).append(r);
            a.addLayer(e, !0);
            e.events.on({
                featureselected: function (a) {
                    b(a.feature)
                }
            });
            a.map.events.register("mousemove", a, c);
            d = !0
        },
        Show: function () {
            d && l()
        },
        Hide: function () {
            e.setVisibility(!1);
            null != a.widgetPop && a.removePopup(a.widgetPop)
        },
        Dispose: function () {
            f && (f.abort(), f = null);
            a.removeLayer(e, !0);
            null != a.widgetPop && a.removePopup(a.widgetPop);
            d = !1;
            r.remove();
            e = r = null;
            a.map.events.unregister("mousemove", a, c)
        },
        isInit: function () {
            return d
        }
    }
}
function WaterConditionWidget() {
    function l(a) {
        e = a;
        0 < f[e].length ? c() : b = $.ajax({
            type: "GET",
            url: Service.RTService + "type=water&op=getwater&param={type:'" + e + "'}",
            dataType: "jsonp",
            success: function (a) {
                if ("object" == typeof a) {
                    for (var b = 0; b < a.length; b++) f[e].push(a[b]);
                    c()
                }
            },
            error: function (a, b, d) {
                console.log && console.log(a)
            }
        })
    }
    function c() {
        var a, b;
        if (k) if (k.removeAllFeatures(), null != h.widgetPop && h.removePopup(h.widgetPop), "river" == e) {
            for (a = 0; a < f[e].length; a++) {
                b = f[e][a];
                var c = new Ol2.Feature.Vector(new Ol2.Geometry.Point(parseFloat(b.X), parseFloat(b.Y))),
                    g = Ol2.Util.extend({},
                        Ol2.Feature.Vector.style["default"]),
                    l = "p.gif";
                "5" == b.ZTYPE ? l = "z.gif" : "4" == b.ZTYPE && (l = "j.gif");
                g.externalGraphic = "../Content/map/images/rain/" + l;
                g.graphicWidth = 11;
                g.graphicHeight = 11;
                g.fillOpacity = 1;
                g.cursor = "pointer";
                c.style = g;
                c.attributes = b;
                k.addFeatures(c)
            }
            d.css({
                width: "73px",
                height: "90px",
                display: "block",
                background: "url('../Content/map/images/rain/k.png')"
            })
        } else {
            for (a = 0; a < f[e].length; a++) b = f[e][a],
                c = new Ol2.Feature.Vector(new Ol2.Geometry.Point(parseFloat(b.X), parseFloat(b.Y))),
                g = Ol2.Util.extend({},
                    Ol2.Feature.Vector.style["default"]),
                l = "z.gif",
                "1" == b.ISLIMIT && (l = "cj.gif"),
                g.externalGraphic = "../Content/map/images/rain/" + l,
                g.graphicWidth = 11,
                g.graphicHeight = 11,
                g.fillOpacity = 1,
                g.cursor = "pointer",
                c.style = g,
                c.attributes = b,
                k.addFeatures(c);
            d.css({
                width: "80px",
                height: "85px",
                display: "block",
                background: "url('../Content/map/images/rain/b.png')"
            })
        }
    }
    function m(a) {
        null != h.widgetPop && h.removePopup(h.widgetPop);
        var b = a.attributes,
            d = b.NAME,
            c;
        "river" == e ? (c = "时间：" + b.TIME, "1" == b.TYPE ? (c += "<br>闸上水位:" + b.Z + " m", c += "<br>闸下水位:" + b.EXT2 + " m") : c += "<br/>水位：" + b.Z + "m", b.Q && (c += "<br>流量：" + b.Q + " m³/s")) : c = "时间：" + b.TIME + "<br/>水位：" + b.Z + " m<br/>蓄水量：" + b.W + " 百万m³<BR>出库流量：" + b.Q + " m³/s";
        h.widgetPop = new Ol2.Popup.FramedCloud("chicken", a.geometry.getBounds().getCenterLonLat(), null, "<div style='padding:0 5px;min-width:130px;'><div style = 'position:absolute;top:0px;color:#3b9cfe;'><b>" + d + "</b></div><div style='line-height:1.5em;margin-top:25px;'>" + c + '</div><div class="river_hist"><div subid="' + b.SUBID + '"></div></div>', null, !0,
            function () {
                h.removePopup(h.widgetPop);
                h.unSelect()
            });
        a.popup = h.widgetPop;
        h.addPopup(h.widgetPop);
        $(".river_hist>div").click(function () {
            var a = $(this).attr("subid");
            g(a)
        })
    }
    function g(a) {
        0 == $("#river_HistFrame").length && ($("body").append("<div id='river_HistFrame'><div style='filter:alpha(opacity:50);opacity:0.3;background:#808080;width:100%;height:100%;position:absolute;left:0;top:0;z-index: 1100'></div><div id='river_Hist_view' style='padding: 5px;border:1px solid #849DF9;border-radius: 5px;position:absolute; left: 50%;top: 50%;margin-top:-260px;padding: 0;margin-left:-480px;width:1000px;height:520px;background-color:white;z-index: 1101'><iframe style='margin: 2px 5px;border: 1px solid #C5C5C5;border-radius: 3px;' width='990' height='512' frameborder='no' border='0' marginwidth='0' marginheight='0' scrolling='no' allowtransparency='yes'></iframe><div style='position: absolute;position: absolute;top: 6px;font-size:14px;left: 12px;color: #1515EF;'>历史信息详情</div><div id='river_Hist_close' style='position: absolute;top:6px;right:6px;width:20px;height:20px; background-image: url(../Content/map/images/close.png);' ></div></div></div>"), $("#river_Hist_close").click(function () {
            $("#river_HistFrame").hide()
        }));
        var b = $("#river_HistFrame").css("display", "block").find("iframe");
        "river" != e ? b.attr("src", "../page/reservoirStatistic.html?id=" + encodeURIComponent(a)) : b.attr("src", "../page/riverStatistic.html?id=" + encodeURIComponent(a))
    }
    if (null != WaterConditionWidget.unique) return WaterConditionWidget.unique;
    WaterConditionWidget.unique = this;
    var h = null,
        k = null,
        b = null,
        a = !1,
        e = "",
        f = {
            reservoir: [],
            river: []
        },
        d;
    return {
        init: function (b, c, e) {
            k = new Ol2.Layer.Vector("水情", {
                style: c,
                renderers: b
            });
            h = e;
            h.addLayer(k, !0);
            k.events.on({
                featureselected: function (a) {
                    m(a.feature)
                }
            });
            d = $("<div style='z-index:980;border:1px solid #696969;position:absolute;right:50px;bottom:50px;'><div style='position: relative;font-size: 14px;color: #3C06E7;font-weight: bold;padding: 7px 1px;left: 50%;margin-left: 11px;'></div></div>");
            $(h.map.div).after(d);
            a = !0
        },
        Show: function (b) {
            b = null == b ? "river" : b.split("_")[1];
            a && b != e && l(b)
        },
        Hide: function () {
            k.setVisibility(!1);
            null != h.widgetPop && h.removePopup(h.widgetPop);
            d.hide()
        },
        Dispose: function () {
            b && (b.abort(), b = null);
            h.removeLayer(k, !0);
            null != h.widgetPop && h.removePopup(h.widgetPop);
            f = {
                river: [],
                water: []
            };
            a = !1;
            e = "";
            d.remove();
            k = null;
            $("river_HistFrame").remove()
        },
        isInit: function () {
            return a
        }
    }
}
function RainWidget() {
    function l(b) {
        h.removeAllFeatures();
        0 < e[a][b].length ? h.addFeatures(e[a][d]) : k = $.ajax({
            type: "GET",
            url: Service.RTService + "type=rain&op=" + a + "&param={k:" + b + "}&_t=" + Date.now(),
            dataType: "jsonp",
            success: function (b) {
                if ("object" == typeof b) {
                    var c = [],
                        f,
                        g;
                    if (!(1 > b.length)) if ("day" != a) {
                        for (var k = f = 0; k < b.length; k++) b[k].val = b[k].VAL ? Math.round(parseFloat(b[k].VAL)) : 0,
                            b[k].val > f && (f = b[k].val);
                        for (var l = 150 / f,
                            k = 0; k < b.length; k++) {
                            f = new Ol2.Feature.Vector(new Ol2.Geometry.Point(parseFloat(b[k].X), parseFloat(b[k].Y)));
                            f.attributes = b[k];
                            g = Ol2.Util.extend({},
                                Ol2.Feature.Vector.style["default"]);
                            g.fillOpacity = 1;
                            g.cursor = "pointer";
                            g.fontSize = "15px";
                            g.fontWeight = "bold";
                            g.graphicWidth = 20;
                            g.externalGraphic = "../Content/map/images/statics/bar.png";
                            var n = Math.round(l * b[k].val);
                            6 > n && (n = 6);
                            g.graphicHeight = n;
                            g.label = b[k].VAL ? Math.round(10 * parseFloat(b[k].VAL)) / 10 + "" : "--";
                            g.labelYOffset = g.graphicHeight / 2 + 6;
                            f.style = g;
                            c.push(f)
                        }
                        e[a][d] = c;
                        r.css({
                            width: "185px",
                            height: "85px",
                            display: "block",
                            background: "url('../Content/map/images/rain/r_legend1.png')"
                        })
                    } else {
                        for (k = 0; k < b.length; k++) f = new Ol2.Feature.Vector(new Ol2.Geometry.Point(parseFloat(b[k].X), parseFloat(b[k].Y))),
                            f.attributes = b[k],
                            g = Ol2.Util.extend({},
                                Ol2.Feature.Vector.style["default"]),
                            g.fillOpacity = 1,
                            g.strokeColor = "gray",
                            g.cursor = "pointer",
                            l = g,
                            n = b[k].VAL,
                            "number" != typeof n && (n = n ? parseFloat(n) : 0),
                            l.fillColor = .1 > n ? "gray" : 1 > n ? "#00ffff" : 25 > n ? "#ffff00" : 50 > n ? "#0c680d" : 100 > n ? "#0000ff" : 200 > n ? "#ff00ff" : "#ff0000",
                            "gray" == g.fillColor ? g.pointRadius = 6 : (g.pointRadius = 10, g.label = b[k].VAL ? Math.round(10 * parseFloat(b[k].VAL)) / 10 + "" : "--", g.labelYOffset = -15, g.fontSize = "15px", g.fontWeight = "bold"),
                            f.style = g,
                            c.push(f);
                        e[a][d] = c;
                        r.css({
                            width: "237px",
                            height: "134px",
                            display: "block",
                            background: "url('../Content/map/images/rain/r_legend2.png')"
                        })
                    }
                    h.addFeatures(e[a][d])
                }
            },
            error: function (a, b, d) {
                console.log && console.log(a)
            }
        })
    }
    function c(b) {
        var c = b.attributes;
        g.widgetPop && g.removePopup(g.widgetPop);
        g.widgetPop = new Ol2.Popup.FramedCloud("chicken", new Ol2.LonLat(b.geometry.x, b.geometry.y), null, "<div style='padding:0 5px;min-width:130px;'><div style = 'position:absolute;top:0px;color:#3b9cfe;'><b>" + c.NAME + " (" + ("month" == a ? "最近一个月雨量" : "最近24小时雨量") + ")</b></div><div style='line-height:1.5em;margin-top:25px;'>总雨量:" + Math.round(10 * parseFloat(c.VAL)) / 10 + " mm</div><div class='rain_hist_frm'><iframe style='margin: 2px 5px;border: 1px solid #C5C5C5;border-radius: 3px;' width='560' height='300' frameborder='no' border='0' marginwidth='0' marginheight='0' scrolling='no' allowtransparency='yes'></iframe></div></div>", null, !0,
            function () {
                g.removePopup(g.widgetPop);
                g.unSelect()
            });
        g.addPopup(g.widgetPop);
        var e = {
            op: "day",
            k: d,
            n: c.NAME,
            bm: c.BM
        };
        "month" == a && (e.op = "days");
        setTimeout(function () {
            $(".rain_hist_frm").find("iframe").attr("src", "../page/rainStatistic.html?" + parseParam(e))
        },
            300)
    }
    function m(a) {
        if (9 > g.map.zoom) {
            if (0 == d && 1 != a) return;
            d = 0
        } else {
            if (1 == d && 1 != a) return;
            d = 1
        }
        l(d)
    }
    if (null != RainWidget.unique) return RainWidget.unique;
    RainWidget.unique = this;
    Date.now();
    var g = null,
        h = null,
        k = null,
        b = !1,
        a = "",
        e = {
            day: [[], []],
            month: [[], []]
        },
        f = !1,
        d = -1,
        r;
    return {
        init: function (a, d, e) {
            h = new Ol2.Layer.Vector("雨情2", {
                style: d,
                renderers: a
            });
            g = e;
            g.addLayer(h, !0);
            h.events.on({
                featureselected: function (a) {
                    c(a.feature)
                }
            });
            r = $("<div style='z-index:980;border:1px solid #696969;position:absolute;right:50px;bottom:50px;'><div style='position: relative;font-size: 14px;color: #3C06E7;font-weight: bold;padding: 7px 1px;left: 50%;margin-left: 11px;'></div></div>");
            $(g.map.div).after(r);
            b = !0
        },
        Show: function (d) {
            d = null == d ? "day" : d.split("_")[1];
            b && d != a && (a = d, m(1), f || (g.map.events.register("zoomend", g.map, m), f = !0))
        },
        Hide: function () {
            h.setVisibility(!1);
            null != g.widgetPop && g.removePopup(g.widgetPop);
            r.hide()
        },
        Dispose: function () {
            k && (k.abort(), k = null);
            g.removeLayer(h, !0);
            null != g.widgetPop && g.removePopup(g.widgetPop);
            e = {
                day: [[], []],
                month: [[], []]
            };
            b = !1;
            a = "";
            h = null;
            f && (g.map.events.unregister("zoomend", g.map, m), f = !1);
            d = void 0;
            r.remove()
        },
        isInit: function () {
            return b
        }
    }
}
function VideoWidget() {
    function l() {
        m = $.ajax({
            type: "POST",
            url: "/Home/GetAllCamera",
            contentType: "application/json",
            dataType: "json",
            success: function (a) {
                b = eval(a.result);
                for (a = 0; a < b.length; a++) {
                    var c = b[a];
                    if (h) {
                        var f = new Ol2.Feature.Vector(new Ol2.Geometry.Point(c.x, c.y)),
                            d = Ol2.Util.extend({},
                                Ol2.Feature.Vector.style["default"]);
                        d.externalGraphic = "../Content/map/images/video/video.png";
                        d.graphicWidth = 24;
                        d.graphicHeight = 24;
                        d.fillOpacity = 1;
                        d.cursor = "pointer";
                        f.style = d;
                        f.attributes = c;
                        h.addFeatures(f)
                    }
                }
            },
            error: function (a, b) {
                console.log && console.log("视频数据请求" + b)
            }
        })
    }
    function c(a) {
        null != g.widgetPop && g.removePopup(g.widgetPop);
        //g.widgetPop = new Ol2.Popup.FramedCloud("chicken", a.geometry.getBounds().getCenterLonLat(), null, '<div id = "PopDiv" style = ""><div id = "PopDiv_title" style="width:420px;height:22px;font-weight:bold;font-size: 14px;line-height: 22px;padding-left: 5px;color:#3b9cfe;"></div><div id = "PopDiv_frame" style="width:430px;height:330px;"><iframe id="popiframe" width="100%" height="100%" frameborder="0"></iframe><div/></div>', null, !0,
        //    function () {
        //        null != g.widgetPop && (g.removePopup(g.widgetPop), g.unSelect())
        //    });
        g.widgetPop = new Ol2.Popup.FramedCloud("chicken", a.geometry.getBounds().getCenterLonLat(), null, '<div id = "PopDiv" style = ""><div id = "PopDiv_title" style="width:420px;height:22px;font-weight:bold;font-size: 14px;line-height: 22px;padding-left: 5px;color:#3b9cfe;"></div><div id = "PopDiv_frame" style="width:430px;height:330px;"><object id="DPSDK_OCX" classid="CLSID:D3E383B6-765D-448D-9476-DFD8B499926D" style="width: 100%; height: 100%" codebase="DpsdkOcx.cab#version=1.0.0.0"></object><div/></div>', null, !0,
            function () {
                null != g.widgetPop && (g.removePopup(g.widgetPop), g.unSelect())
            });
        a.popup = g.widgetPop;
        a.popup.autoSize = !0;
        g.addPopup(g.widgetPop);
        var b;
        "1" == a.attributes.type ? (b = "video/iermu.html?title=123" + encodeURI(a.attributes.name) + "&" + a.attributes.request, $("#PopDiv_frame").css("width", "470px"), $("#PopDiv_frame").css("height", "333px")) : "2" == a.attributes.type ? (b = "video/anqiaoqiao.html?title=" + encodeURI(a.attributes.name) + "&request=" + a.attributes.request, $("#PopDiv_frame").css("width", "430px"), $("#PopDiv_frame").css("height", "330px")) : (b = "http://www.sdmap.gov.cn/map/video/square.html?title=" + encodeURI(a.attributes.name) + "&request=" + a.attributes.request, $("#PopDiv_frame").css("width", "440px"), $("#PopDiv_frame").css("height", "340px"));
        a.popup.updateSize();
        //$("#popiframe").attr("src", b);
        $("#PopDiv_title").empty();
        $("#PopDiv_title").html(a.attributes.name);

        monitorInit();//初始化视频监控
        ButtonStartRealplayByWndNo_onclick(a.attributes.request);//打开视频
    }
    if (null != VideoWidget.unique) return VideoWidget.unique;
    VideoWidget.unique = this;
    var m = null,
        g = null,
        h = null,
        k = !1,
        b = [{
            id: "wrs",
            name: "望人松",
            x: 117.106774,
            y: 36.246327
        },
        {
            id: "gongbei",
            name: "拱北石",
            x: 117.106063,
            y: 36.256359
        },
        {
            id: "wydz",
            name: "天街",
            x: 117.098694,
            y: 36.2558
        },
        {
            id: "nantian",
            name: "南天门",
            x: 117.098355,
            y: 36.255723
        }];
    return {
        init: function (a, b, f) {
            h = new Ol2.Layer.Vector("视频", {
                style: b,
                renderers: a
            });
            g = f;
            g.addLayer(h, !0);
            h.events.on({
                featureselected: function (a) {
                    c(a.feature);
                }
            });
            k = !0
        },
        Show: function (a) {
            k && l(a)
        },
        Hide: function () {
            h.setVisibility(!1);
            null != g.widgetPop && g.removePopup(g.widgetPop)
        },
        Dispose: function () {
            m && (m.abort(), m = null);
            g.removeLayer(h, !0);
            null != g.widgetPop && g.removePopup(g.widgetPop);
            k = !1;
            h = null
        },
        isInit: function () {
            return k
        }
    }
}
function PopulationWidget() {
    function l(a) {
        a != w && (null != b.widgetPop && b.removePopup(b.widgetPop), w = a, "rkzs" == w ? (y && y.abort(), n.css({
            width: "166px",
            height: "82px",
            display: "block",
            background: "url('../Content/map/images/statics/rk_legend1.png')"
        }), 0 < f.length ? 557114 < b.map.getScale() ? g(2) : g(3) : y = $.ajax({
            type: "GET",
            url: "../MapService/proxy.ashx?http://www.sdmap.gov.cn:8081/Statistics/StatisticsService.asmx/GetRKZS?year=2015",
            datatype: "xml",
            success: function (a) {
                m(a)
            },
            error: function (a, b) {
                console.log && console.log("人口统计数据请求" + b)
            }
        })) : (y && y.abort(), n.css({
            width: "381px",
            height: "148px",
            display: "block",
            background: "url('../Content/map/images/statics/rk_legend.png')"
        }), 0 < r.length ? g() : y = $.ajax({
            type: "GET",
            url: "../MapService/proxy.ashx?http://www.sdmap.gov.cn:8081/Statistics/StatisticsService.asmx/GetRKMD?year=2015&level=3",
            datatype: "xml",
            success: function (a) {
                m(a)
            },
            error: function (a, b) {
                console.log && console.log("人口统计数据请求" + b)
            }
        })))
    }
    function c(a) {
        557114 < b.map.getScale() ? 3 == t && g(2) : 2 == t && g(3)
    }
    function m(a) {
        if (a) {
            var c;
            c = a.documentElement.textContent || a.documentElement.text;
            c = eval("(" + c + ")");
            a = c.Result;
            var e = c.Count;
            0 < e && n.children("div").text("(" + a[0].year + "年)");
            if ("rkzs" == w) {
                for (c = 0; c < e; c++) "2" == a[c].level ? f.push(a[c]) : d.push(a[c]);
                557114 < b.map.getScale() ? g(2) : g(3)
            } else {
                var h = new Ol2.Format.WKT;
                for (c = 0; c < e; c++) r.push({
                    rkmd: a[c].rkmd,
                    geom: h.read(a[c].geometry)
                });
                g()
            }
        }
    }
    function g(b) {
        if (a) if (a.removeAllFeatures(), "rkzs" == w) {
            t = b;
            var c, e, g, h, k;
            if (2 == t) for (g = 0, h = f.length; g < h; g++) e = f[g],
                b = new Ol2.Feature.Vector(new Ol2.Geometry.Point(e.x, e.y)),
                c = Ol2.Util.extend({},
                    Ol2.Feature.Vector.style["default"]),
                c.externalGraphic = "../Content/map/images/statics/point.png",
                k = parseInt(Math.sqrt(2 * e.rkzs)),
                c.graphicWidth = k,
                c.graphicHeight = k,
                c.fillOpacity = 1,
                c.cursor = "pointer",
                b.style = c,
                b.attributes = e,
                a.addFeatures(b);
            else for (g = 0, h = d.length; g < h; g++) e = d[g],
                b = new Ol2.Feature.Vector(new Ol2.Geometry.Point(e.x, e.y)),
                c = Ol2.Util.extend({},
                    Ol2.Feature.Vector.style["default"]),
                c.externalGraphic = "../Content/map/images/statics/point.png",
                k = parseInt(Math.sqrt(20 * e.rkzs)),
                c.graphicWidth = k,
                c.graphicHeight = k,
                c.fillOpacity = 1,
                c.cursor = "pointer",
                b.style = c,
                b.attributes = e,
                a.addFeatures(b)
        } else for (g = 0, h = r.length; g < h; g++) e = r[g],
            b = e.geom,
            c = Ol2.Util.extend({},
                Ol2.Feature.Vector.style["default"]),
            k = 3E3 < e.rkmd ? "#6b0000" : 800 < e.rkmd ? "#ad5313" : 500 < e.rkmd ? "#f2a72e" : 300 < e.rkmd ? "#fad155" : "#ffff80",
            c.strokeColor = "#ffffff",
            c.strokeOpacity = .75,
            c.fillColor = k,
            c.strokeWidth = 1,
            c.fillOpacity = .75,
            c.cursor = "pointer",
            b.style = c,
            b.attributes = {
                rkmd: e.rkmd
            },
            a.addFeatures(b)
    }
    function h() {
        q.style.fillOpacity = .75;
        a.drawFeature(q);
        b.removePopup(b.widgetPop);
        q = null;
        b.unSelect()
    }
    function k(d) {
        function c() {
            $("#staticsDiv").highcharts({
                chart: {
                    type: "column"
                },
                title: {
                    text: ""
                },
                legend: {
                    enabled: !1
                },
                xAxis: {
                    categories: l
                },
                yAxis: {
                    min: 0,
                    title: {
                        text: "万人"
                    }
                },
                tooltip: {
                    headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
                    pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td><td style="padding:0"><b>{point.y:.1f}万</b></td></tr>',
                    footerFormat: "</table>",
                    shared: !0,
                    useHTML: !0
                },
                series: [{
                    name: "人口数",
                    data: n,
                    dataLabels: {
                        formatter: function () {
                            return this.point.name
                        },
                        color: "yellow",
                        distance: -15
                    }
                }]
            })
        }
        function e() {
            $("#staticsDiv").highcharts({
                chart: {
                    plotBackgroundColor: null,
                    plotBorderWidth: null,
                    plotShadow: !1
                },
                legend: {
                    align: "center"
                },
                title: {
                    text: ""
                },
                tooltip: {
                    pointFormat: "{series.name}: <b>{point.percentage:.1f}%</b>"
                },
                plotOptions: {
                    pie: {
                        allowPointSelect: !0,
                        cursor: "pointer",
                        dataLabels: {
                            enabled: !0,
                            color: "#000000",
                            connectorColor: "#000000",
                            format: "<b>{point.y}</b>"
                        },
                        showInLegend: !0
                    }
                },
                series: [{
                    type: "pie",
                    name: "百分比",
                    data: g,
                    size: "100%",
                    dataLabels: {
                        formatter: function () {
                            return this.point.name
                        },
                        color: "white",
                        distance: -25
                    }
                }]
            })
        }
        null != b.widgetPop && b.removePopup(b.widgetPop);
        if ("rkmd" == w) q && (q.style.fillOpacity = .75, a.drawFeature(q)),
            q = d,
            b.widgetPop = new Ol2.Popup("文本标注", d.geometry.getBounds().getCenterLonLat(), new Ol2.Size(80, 18), "<div style = 'position:relative; cursor:pointer;'><b>" + d.attributes.rkmd + "</div>", !0, h),
            q.style.fillOpacity = .5,
            a.drawFeature(q),
            d.popup = b.widgetPop,
            b.addPopup(b.widgetPop);
        else {
            var f = "";
            2 == t && (f = "<div id = 'staticsTab2'><div class='stc_xqpic'></div><div class='stc_title'>县区比例图</div></div>");
            b.widgetPop = new Ol2.Popup.FramedCloud("chicken", d.geometry.getBounds().getCenterLonLat(), null, "<div style='padding:0 5px;'><div style = 'position:relative;font-size: 14px; margin-bottom:10px;cursor:pointer;color:#3b9cfe;'><b>" + d.attributes.name + "人口数据</b> </div><div class='maindiv'><div class='titlediv' ><div id = 'staticsTab1'><div class='stc_hispic active'></div><div class='stc_title active'>历年对比图</div></div>" + f + "</div><div id = 'staticsDiv'></div></div></div>", null, !0,
                function () {
                    b.removePopup(b.widgetPop);
                    b.unSelect()
                });
            d.popup = b.widgetPop;
            b.addPopup(b.widgetPop);
            d = $.ajax({
                url: "../MapService/proxy.ashx?http://www.sdmap.gov.cn:8081/Statistics/StatisticsService.asmx/GetHistoryRKZS?pac=" + d.attributes.pac + "&year=2015",
                dataType: "xml",
                async: !1
            });
            d = d.responseText;
            d = d.substring(76, d.length - 9);
            d = eval("(" + d + ")");
            var g = [];
            if (0 < d.items.length) for (var f = 0,
                k = d.items.length; f < k; f++) g.push({
                    name: d.items[f].name,
                    y: parseFloat(d.items[f].rkzs)
                });
            var l = [],
                n = [],
                f = 0;
            for (count = d.Count; f < count; f++) n.push(parseFloat(d.Result[f].rkzs)),
                l.push(d.Result[f].year);
            $(".titlediv>div").click(function (a) {
                a = $(this);
                "staticsTab1" == this.id ? c() : e();
                a.children().addClass("active");
                a.siblings().children().removeClass("active")
            });
            c()
        }
    }
    if (null != PopulationWidget.unique) return PopulationWidget.unique;
    PopulationWidget.unique = this;
    var b = null,
        a = null,
        e = !1,
        f = [],
        d = [],
        r = [],
        t,
        n = null,
        w = "",
        y = null,
        q = null;
    return {
        init: function (d, c, f) {
            a = new Ol2.Layer.Vector("人口", {
                style: c,
                renderers: d
            });
            b = f;
            b.addLayer(a, !0);
            a.events.on({
                featureselected: function (a) {
                    k(a.feature)
                }
            });
            n = $("<div style='z-index:980;border:1px solid #696969;position:absolute;right:50px;bottom:50px;'><div style='position: relative;font-size: 14px;color: #3C06E7;font-weight: bold;padding: 7px 1px;left: 50%;margin-left: 11px;'></div></div>");
            $(b.map.div).after(n);
            e = !0
        },
        Show: function (a) {
            a = null == a ? "rkzs" : a.split("_")[1];
            e && (l(a), b.map.events.register("zoomend", b.map, c))
        },
        Hide: function () {
            a.setVisibility(!1);
            null != b.widgetPop && b.removePopup(b.widgetPop);
            n.hide()
        },
        Dispose: function () {
            y && (y.abort(), y = null);
            b.removeLayer(a, !0);
            null != b.widgetPop && b.removePopup(b.widgetPop);
            b.map.events.unregister("zoomend", b.map, c);
            e = !1;
            a = null;
            n.remove();
            n = null;
            w = "";
            f = [];
            d = [];
            r = []
        },
        isInit: function () {
            return e
        }
    }
}
function EconomicWidget() {
    function l(a) {
        a != t && (null != b.widgetPop && b.removePopup(b.widgetPop), t = a, 0 < d[t].length ? c() : (a = "gdp" == t ? "/GetGDP?year=2015" : "czsr" == t ? "/GetCZSR?year=2015" : "/GetBQX?year=2015", n && n.abort(), n = $.ajax({
            type: "GET",
            url: "../MapService/proxy.ashx?http://www.sdmap.gov.cn:8081/Statistics/StatisticsService.asmx" + a,
            datatype: "xml",
            success: function (a) {
                m(a)
            },
            error: function (a, b) {
                console.log && console.log(t + "数据请求" + b)
            }
        })))
    }
    function c(a) {
        557114 < b.map.getScale() ? 3 != r && a || g(2) : 2 != r && a || g(3)
    }
    function m(a) {
        if (a) {
            var c;
            c = a.documentElement.textContent || a.documentElement.text;
            c = eval("(" + c + ")");
            a = c.Result;
            var e = c.Count;
            0 < e && f.children("div").text("(" + a[0].year + "年)");
            var h = [],
                k = [];
            if ("bqx" != t) {
                for (c = 0; c < e; c++) "2" == a[c].level ? h.push(a[c]) : k.push(a[c]);
                d[t] = [h, k];
                557114 < b.map.getScale() ? g(2) : g(3)
            } else d[t] = a,
                g()
        }
    }
    function g(b) {
        if (a) {
            a.removeAllFeatures();
            r = b;
            var c, e, g, h, k, l = [];
            if ("gdp" == t) for (f.css({
                width: "185px",
                height: "85px",
                display: "block",
                background: "url('../Content/map/images/statics/jj_legend1.png')"
            }), k = d[t][r - 2], g = 0, h = k.length; g < h; g++) e = k[g],
                b = new Ol2.Feature.Vector(new Ol2.Geometry.Point(e.x, e.y)),
                c = Ol2.Util.extend({},
                    Ol2.Feature.Vector.style["default"]),
                c.fillOpacity = 1,
                c.cursor = "pointer",
                c.externalGraphic = "../Content/map/images/statics/bar.png",
                c.graphicWidth = 20,
                c.graphicHeight = 2 == r ? parseInt(e.sczz / 100) : parseInt(e.sczz / 10),
                b.style = c,
                b.attributes = e,
                l.push(b);
            else if ("czsr" == t) {
                f.css({
                    width: "167px",
                    height: "83px",
                    display: "block",
                    background: "url('../Content/map/images/statics/jj_legend2.png')"
                });
                var n;
                k = d[t][r - 2];
                g = 0;
                for (h = k.length; g < h; g++) e = k[g],
                    b = new Ol2.Feature.Vector(new Ol2.Geometry.Point(e.x, e.y)),
                    c = Ol2.Util.extend({},
                        Ol2.Feature.Vector.style["default"]),
                    c.fillOpacity = 1,
                    c.cursor = "pointer",
                    c.externalGraphic = "../Content/map/images/statics/boll.png",
                    n = 2 == r ? parseInt(Math.sqrt(8 * e.dfsr)) : parseInt(Math.sqrt(40 * e.dfsr)),
                    c.graphicWidth = c.graphicHeight = n,
                    b.style = c,
                    b.attributes = e,
                    l.push(b)
            } else for (f.css({
                width: "145px",
                height: "85px",
                display: "block",
                background: "url('../Content/map/images/statics/jj_legend3.png')"
            }), k = d[t], g = 0, h = k.length; g < h; g++) e = k[g],
                b = new Ol2.Feature.Vector(new Ol2.Geometry.Point(e.x, e.y)),
                c = Ol2.Util.extend({},
                    Ol2.Feature.Vector.style["default"]),
                c.fillOpacity = 1,
                c.cursor = "pointer",
                c.externalGraphic = "../Content/map/images/statics/boll.png",
                c.graphicWidth = c.graphicHeight = 40,
                c.label = e.name + "第" + e.order + "位",
                c.labelYOffset = -25,
                c.fontColor = "blue",
                c.fontWeight = "bold",
                b.style = c,
                b.attributes = e,
                l.push(b);
            a.addFeatures(l)
        }
    }
    function h() {
        b.removePopup(b.widgetPop);
        b.unSelect()
    }
    function k(a) {
        function d() {
            $("#staticsDiv").highcharts({
                chart: {
                    type: "column"
                },
                title: {
                    text: ""
                },
                legend: {
                    enabled: !1
                },
                xAxis: {
                    categories: n
                },
                yAxis: {
                    min: 0,
                    title: {
                        text: "亿元"
                    }
                },
                tooltip: {
                    headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
                    pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td><td style="padding:0"><b>{point.y:.1f}亿元</b></td></tr>',
                    footerFormat: "</table>",
                    shared: !0,
                    useHTML: !0
                },
                series: [{
                    name: f,
                    data: l,
                    size: "30%",
                    dataLabels: {
                        formatter: function () {
                            return this.point.name
                        },
                        color: "yellow",
                        distance: -15
                    }
                }]
            })
        }
        function c() {
            $("#staticsDiv").highcharts({
                chart: {
                    plotBackgroundColor: null,
                    plotBorderWidth: null,
                    plotShadow: !1
                },
                legend: {
                    align: "center"
                },
                title: {
                    text: ""
                },
                tooltip: {
                    pointFormat: "{series.name}: <b>{point.percentage:.1f}%</b>"
                },
                plotOptions: {
                    pie: {
                        allowPointSelect: !0,
                        cursor: "pointer",
                        dataLabels: {
                            enabled: !0,
                            color: "#000000",
                            connectorColor: "#000000",
                            format: "<b>{point.y}</b>"
                        },
                        showInLegend: !0
                    }
                },
                series: [{
                    type: "pie",
                    name: "百分比",
                    data: G,
                    size: "100%",
                    dataLabels: {
                        formatter: function () {
                            return this.point.name
                        },
                        color: "white",
                        distance: -25
                    }
                }]
            })
        }
        null != b.widgetPop && b.removePopup(b.widgetPop);
        if ("bqx" == t) b.widgetPop = new Ol2.Popup.FramedCloud("chicken", a.geometry.getBounds().getCenterLonLat(), null, "<div style ='position:relative;margin:0 5px;cursor:pointer;color:#3B9CFE;font-size:14px;'><b>" + a.attributes.name + "</b></div ><br/><div style='margin:0 6px;'>国民生产总值(GDP):" + a.attributes.sczz + "亿元<br/>财政收入：" + a.attributes.dfsr + "亿元</div>", null, !0, h),
            a.popup = b.widgetPop,
            b.addPopup(b.widgetPop);
        else {
            var e = "",
                f, g, k;
            "gdp" == t ? (g = "/GetHistoryGDP", f = "国民生产总值(GDP)", k = "sczz") : (g = "/GetHistoryCZSR", f = "财政收入", k = "dfsr");
            2 == r && (e = "<div id = 'staticsTab2'><div class='stc_xqpic'></div><div class='stc_title'>县区比例图</div></div>");
            b.widgetPop = new Ol2.Popup.FramedCloud("chicken", a.geometry.getBounds().getCenterLonLat(), null, "<div style='padding:0 5px;'><div style = 'position:relative;font-size: 14px; margin-bottom:10px;cursor:pointer;color:#3b9cfe;'><b>" + a.attributes.name + f + "</b> </div><div class='maindiv'><div class='titlediv' ><div id = 'staticsTab1'><div class='stc_hispic active'></div><div class='stc_title active'>历年对比图</div></div>" + e + "</div><div id = 'staticsDiv'></div></div></div>", null, !0, h);
            a.popup = b.widgetPop;
            b.addPopup(b.widgetPop);
            a = $.ajax({
                url: "proxy/proxy.ashx?http://www.sdmap.gov.cn:8081/Statistics/StatisticsService.asmx" + g + "?pac=" + a.attributes.pac + "&year=2013",
                dataType: "xml",
                async: !1
            });
            a = a.responseText;
            a = a.substring(76, a.length - 9);
            a = eval("(" + a + ")");
            var e = 0,
                l = [],
                n = [],
                m,
                w;
            m = 0;
            for (g = a.Count; m < g; m++) w = parseFloat(a.Result[m][k]),
                0 != w && (l.push(w), n.push(a.Result[m].year), e > l[m] && (e = l[m]));
            var G = [];
            if (0 < a.items.length) for (m = 0, g = a.items.length; m < g; m++) G.push({
                name: a.items[m].name,
                y: parseFloat(a.items[m][k])
            });
            $(".titlediv>div").click(function (a) {
                a = $(this);
                "staticsTab1" == this.id ? d() : c();
                a.children().addClass("active");
                a.siblings().children().removeClass("active")
            });
            d()
        }
    }
    if (null != EconomicWidget.unique) return EconomicWidget.unique;
    EconomicWidget.unique = this;
    var b = null,
        a = null,
        e = !1,
        f, d = {
            gdp: [],
            czsr: [],
            bqx: []
        },
        r,
        t = "",
        n = null;
    return {
        init: function (d, c, g) {
            a = new Ol2.Layer.Vector("经济", {
                style: new Ol2.StyleMap({
                    "default": {
                        strokeColor: "red",
                        strokeOpacity: .8,
                        strokeWidth: 2,
                        fillColor: "red",
                        fillOpacity: .8,
                        pointRadius: 4,
                        pointerEvents: "visiblePainted",
                        label: "${label}",
                        fontColor: "blue",
                        fontSize: "12px",
                        fontFamily: "SimHei",
                        fontWeight: "bold",
                        labelOutlineColor: "white",
                        labelOutlineWidth: 1
                    }
                }),
                renderers: d
            });
            b = g;
            b.addLayer(a, !0);
            a.events.on({
                featureselected: function (a) {
                    k(a.feature)
                }
            });
            f = $("<div style='z-index:980;border:1px solid #696969;position:absolute;right:50px;bottom:50px;'><div style='position: relative;font-size: 14px;color: #3C06E7;font-weight: bold;padding: 7px 1px;left: 50%;margin-left: 11px;'></div></div>");
            $(b.map.div).after(f);
            e = !0
        },
        Show: function (a) {
            a = null == a ? "gdp" : a.split("_")[1];
            e && (l(a), b.map.events.register("zoomend", b.map, c))
        },
        Hide: function () {
            a.setVisibility(!1);
            null != b.widgetPop && b.removePopup(b.widgetPop);
            f.hide()
        },
        Dispose: function () {
            n && (n.abort(), n = null);
            b.removeLayer(a, !0);
            null != b.widgetPop && b.removePopup(b.widgetPop);
            b.map.events.unregister("zoomend", b.map, c);
            a = null;
            e = !1;
            f.remove();
            d = {
                gdp: [],
                czsr: [],
                bqx: []
            };
            t = ""
        },
        isInit: function () {
            return e
        }
    }
}
function ScenicWidget() {
    function l() {
        0 < r.length ? m() : d = $.ajax({
            type: "GET",
            url: "../MapService/proxy.ashx?http://www.sdmap.gov.cn:8081/sdmapServices/ScenicWebService.asmx/GetHotScenics?scale=2000",
            datatype: "xml",
            success: function (a) {
                c(a)
            },
            error: function (a, b) {
                console.log && console.log("旅游数据请求" + b)
            }
        })
    }
    function c(a) {
        if (a) {
            var b, d = a.documentElement.textContent || a.documentElement.text,
                d = eval(d),
                c = [],
                e = [],
                f = [];
            a = 0;
            for (b = d.length; a < b; a++) "100000" == d[a].scale ? c.push(d[a]) : "414059" == d[a].scale ? e.push(d[a]) : f.push(d[a]);
            r = [c, e, f];
            m()
        }
    }
    function m() {
        if (e) {
            var d, c, f = [],
                g = [];
            1E5 >= b.map.getScale() ? (f = r[0].concat(r[1]).concat(r[2]), a = 3) : 414059 >= b.map.getScale() ? (f = r[1].concat(r[2]), a = 2) : 9999999 >= b.map.getScale() && (f = r[2], a = 1);
            d = 0;
            for (c = f.length; d < c; d++) {
                var h = new Ol2.Feature.Vector(new Ol2.Geometry.Point(f[d].x, f[d].y)),
                    k = Ol2.Util.extend({},
                        Ol2.Feature.Vector.style["default"]);
                k.externalGraphic = "http://www.sdmap.gov.cn:8081/pics/thumbnail/" + f[d].id + ".jpg";
                k.graphicWidth = 80;
                k.graphicHeight = 53;
                k.fillOpacity = 1;
                k.cursor = "pointer";
                h.style = k;
                h.attributes = f[d];
                g.push(h)
            }
            e.removeAllFeatures();
            e.addFeatures(g)
        }
    }
    function g(a) {
        null != b.widgetPop && (b.removePopup(b.widgetPop), c = $("#ssss_conn"));
        "string" == typeof k && (k = $(k));
        var c = k;
        d = $.ajax({
            url: "../MapService/proxy.ashx?http://www.sdmap.gov.cn:8081/sdmapServices/ScenicWebService.asmx/GetScenicInfo?scenicId=" + a.attributes.id,
            datatype: "xml",
            async: !1
        });
        var e = d.responseText,
            e = e.substring(76, e.length - 9),
            e = eval("(" + e + ")"),
            f,
            g = [],
            h;
        h = !1;
        var l;
        c.find("#s_title_cont").text(e.nameCn);
        var m = e.pictures;
        for (f = 0; f < m.length; f++) "图片" == m[f].phoFormat ? (g.push("<li><img width='32'height='32'src='http://www.sdmap.gov.cn:8081/pics" + m[f].phoPath + "'/></li>"), h || (c.find("#s_reppic img").attr("src", "http://www.sdmap.gov.cn:8081/pics" + m[f].phoPath), h = !0)) : "视频" == m[f].phoFormat && (l = f);
        c.find("#s_gallery .imglist").empty().append(g.join(""));
        h = e.scenicLevel.length - 1;
        f = 0;
        for (g = []; f < h; f++) g.push("<img src='../Content/map/images/scenic/bookmark.png'/>");
        c.find("#s_jian_tj").empty().append(g.join(""));
        c.find("#s_jian_jb").attr("title", e.scenicLevel).text(e.scenicLevel);
        c.find("#s_jian_lx").attr("title", e.scenicTypes).text(e.scenicTypes);
        c.find("#s_jian_mp").text(e.scenicPrices[0].priceType + e.scenicPrices[0].price);
        h = e.contacts;
        f = 0;
        for (g = []; f < h.length; f++) g.push(h[f].BusType + h[f].contactType + ":" + h[f].contact);
        h = g.join(",");
        c.find("#s_jian_lianx").attr("title", h).text(h);
        "" != e.comWebsite && c.find("#s_jian_url").attr("href", e.comWebsite);
        c.find("#s_jian_addr").text(e.address);
        h = e.bestSeasons;
        c.find("#s_jian_bst").text("");
        null != l && c.find("#s_video embed").attr("flashvars", "vcastr_file=http://www.sdmap.gov.cn:8081/pics" + m[l].phoPath + "&IsAutoPlay=0");
        c.find("#s_xq_cont").text(e.attdesM);
        c.find("#s_jt_zx").text(e.trafficInf);
        c.find("#s_jt_ly").text(e.busInf);
        c.find("#s_jt_zj").text(e.selfDrInf);
        c.find("#s_jt_tc").text(e.suppSerFac);
        "1" == e.ifGasstation && c.find("#s_jt_jy").text(e.gasStationName + "距离" + e.nameCn + "约" + e.disGasStation + "公里");
        c.find("#s_fw_xm").text("无信息");
        c.find("#s_fw_jj").text(e.exposterPrice);
        c.find("#s_fw_pt").text(e.suppSerFac);
        c.find("#s_fw_hd").text("无信息");
        c.find("#s_fw_rq").text(e.adaptGroups);
        c.find("#s_fw_kk").text(e.viewdegree);
        c.find("#s_fw_cj").text(e.incitement);
        l = new Ol2.Size(486, 285);
        b.widgetPop = new Ol2.Popup.FramedCloud("chicken", a.geometry.getBounds().getCenterLonLat(), l, c.html(), null, !1);
        a.popup = b.widgetPop;
        b.addPopup(b.widgetPop);
        $("#close_popup").click(function () {
            b.removePopup(b.widgetPop);
            b.unSelect()
        });
        $("#s_gallery").xslider({
            unitdisplayed: 4,
            movelength: 1,
            unitlen: 33
        });
        $("#s_title :button").click(function (a) {
            a = $(this);
            var b = a.index();
            a.css("color", "blue").siblings().css("color", "black");
            $("#s_content>div:eq(" + b + ")").css("display", "block").siblings().css("display", "none")
        });
        $("#s_gallery .imglist_w li").click(function () {
            var a = $(this);
            a.css("border", "solid 2px blueviolet").siblings().css("border", "solid 1px #ddd");
            a = a.children().attr("src");
            $("#s_reppic img").attr("src", a)
        })
    }
    function h() {
        var d = !1;
        1E5 > b.map.getScale() ? 3 != a && (d = !0) : 414059 > b.map.getScale() ? 2 != a && (d = !0) : 9999999 >= b.map.getScale() && 1 != a && (d = !0);
        d && m()
    }
    if (null != ScenicWidget.unique) return ScenicWidget.unique;
    ScenicWidget.unique = this;
    var k = "<div id='ssss_conn'><div id='s_title' style='width: 460px;height: 25px;'><span id='s_title_cont' style='color: #ff9800;font-size: 14px;font-weight: bold;padding-left:10px;'></span><div style='position:absolute;right:20px;top:0'><input type='button' style='color:blue;' value='景区简介' /><input type='button' value='景区详情' /><input type='button' value='交通指南' /><input type='button' value='服务指南' /></div><img id='close_popup' src='../Content/map/images/close.gif' style='position:absolute;top:2px;right:0'/></div><div id='s_content' style='width: 460px;padding-top: 5px; height:245px;background-color: white'><div id='s_jianjie' style='display: block'><div style='float: left;width: 210px'><div id='s_reppic'><img src='' width='208' height='208' /></div><div class='scrolllist' id='s_gallery'><a class='abtn aleft' href='#left' title='左移'></a><div class='imglist_w'><ul class='imglist'></ul></div><a class='abtn aright' href='#right' title='右移'></a></div></div><div class='jianjie' style='float: left;margin-left: 10px;width: 230px;overflow:hidden;white-space: nowrap'>推荐度：<span id='s_jian_tj'></span><br />景点级别：<span id='s_jian_jb'></span><br />景区类型:<span id='s_jian_lx'></span><br />门票信息：<span id='s_jian_mp'></span><br /> 联系方式：<span id='s_jian_lianx'></span><br />景区网址：<span><a id='s_jian_url' href='' target='_blank'>点击查看详情</a></span><br />详细地址：<span id='s_jian_addr'></span><br />最佳浏览季节：<span id='s_jian_bst'></span></div></div><div id='s_xiangqing' style='display: none'><div id='s_video' style='width: 256px;height: 244px;float: left;'><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='256' height='244'><param name='movie' value='third/vcastr22.swf'></param><param name='quality' value='high'></param><param name='allowFullScreen' value='false'></param><embed src='third/vcastr22.swf' allowfullscreen='true' flashvars='vcastr_file=' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='256' height='244' /></object></div><div id='s_xq_cont' style='width:188px;float: left ;height: 230px;margin-left: 10px;padding: 0;line-height: 16px;'></div></div><div id='s_jiaotong' style='display: none;'><div style='height: 47px;'><div style='float: left;width:82px;font-size: 13px;font-weight: bold; '>交通咨询：</div><div id='s_jt_zx' style='float: left;overflow-y: auto;padding: 4px 0; width: 370px'></div></div><div style='height: 47px;'><div style='float: left;width:82px;font-size: 13px;font-weight: bold;'>旅游专线：</div><div id='s_jt_ly' style='float: left;overflow-y: auto;padding: 4px 0; width: 370px;height: 47px'></div></div><div style='height: 47px;'><div style='float: left;width:82px;font-size: 13px;font-weight: bold;'>自驾指南：</div><div id='s_jt_zj' style='float: left;overflow-y: auto;padding: 4px 0;width: 370px;height: 47px'></div></div><div style='height: 27px;'><div style='float: left;width:92px;font-size: 13px;font-weight: bold;'>停车场信息：</div><div id='s_jt_tc' style='float: left;overflow-y: auto;padding: 4px 0;width: 358px;height: 47px'></div></div><div style='height: 27px;'><div style='float: left;width:82px;font-size: 13px;font-weight: bold;'>加油站：</div><div id='s_jt_jy' style='float:left;overflow-y: auto;width: 350px'></div></div></div><div id='s_fuwu' style='display:none;line-height: 20px'><div style='height: 36px;'><div style='float: left;width:102px;font-size: 13px;font-weight: bold;'>景区旅游项目：</div><div id='s_fw_xm' style='float: left;overflow-y: auto; width: 345px;height: 36px'></div></div><div style='height: 36px;'><div style='float: left;width:102px;font-size: 13px;font-weight: bold;'>讲解员价格：</div><div id='s_fw_jj' style='float: left;overflow-y: auto;width: 350px;height:36px'></div></div><div style='height: 47px;'><div style='float: left;width:102px;font-size: 13px;font-weight: bold;'>配套服务设施：</div><div id='s_fw_pt' style='float: left;overflow-y: auto;width: 345px;height: 47px'></div></div><div style='height: 47px;'><div style='float: left;width:102px;font-size: 13px;font-weight: bold;'>常设旅游活动：</div><div id='s_fw_hd' style='float: left;overflow-y:uto;width: 350px;height: 47px;'></div></div><div style='height: 27px;'><div style='float: left;width:82px;font-size: 13px;font-weight: bold;'>适合人群：</div><div id='s_fw_rq' style='float: left;overflow-y: auto;width: 350px;height: 27px;'></div></div><div style='height: 27px;'><div style='float: left;width:82px;font-size: 13px;font-weight: bold;'>可看度：</div><div id='s_fw_kk' style='float: left;overflow-y: auto;width: 350px;height: 27px;'></div></div><div style='height: 27px;'><div style='float: left;width:82px;font-size: 13px;font-weight: bold;'>刺激度：</div><div id='s_fw_cj' style='float: left;overflow-y: auto;width: 350px;height: 27px;'></div></div></div></div></div>",
        b = null,
        a, e = null,
        f = !1,
        d = null,
        r = [];
    return {
        init: function (a, d, c) {
            e = new Ol2.Layer.Vector("景点", {
                style: d,
                renderers: a
            });
            b = c;
            b.addLayer(e, !0);
            e.events.on({
                featureselected: function (a) {
                    g(a.feature)
                }
            });
            f = !0
        },
        Show: function () {
            f && (l(), b.map.events.register("zoomend", b.map, h))
        },
        Hide: function () {
            e.setVisibility(!1);
            null != b.widgetPop && b.removePopup(b.widgetPop)
        },
        Dispose: function () {
            d && (d.abort(), d = null);
            b.removeLayer(e, !0);
            null != b.widgetPop && b.removePopup(b.widgetPop);
            f = !1;
            b.map.events.unregister("zoomend", b.map, h);
            e = null;
            r = []
        },
        isInit: function () {
            return f
        }
    }
}
var WidgetManger = function () {
    function l(b, a) {
        c[b] && (!c[b].isInit() && c[b].init(g, m, h), a ? c[b].Show(a) : c[b].Show())
    }
    var c, m, g, h, k = !1;
    return {
        init: function (b) {
            function a() {
                var a = $("#Rw_top_img"),
                    b = $("#Top_label");
                $("#Rw_top_back").addClass("hide");
                a.addClass("hide");
                b.html("共享信息")
            }
            //'<li id="waterc" class="rightBtn"><div></div>水情        <ul class="rightBtnUl" style="width: 65px; top: 150px; display: none;">            <li id="r_river" class="rightBtnList selitem">河道站</li>            <li id="r_reservoir" class="rightBtnList">水库站</li>        </ul>    </li>    <li id="rain" class="rightBtn"><div></div>雨情        <ul class="rightBtnUl" style="width: 65px; top: 183px; display: none;">            <li id="r_day" class="rightBtnList selitem">近24h雨量</li>            <li id="r_month" class="rightBtnList">近月雨量</li>        </ul>    </li>    <li id="scenic" class="rightBtn"><div></div>景点</li>    <li id="video" class="rightBtn"><div></div>视频</li>    <li id="population" class="rightBtn"><div></div>人口        <ul class="rightBtnUl" style="width: 86px; top: 282px; display: none;">            <li id="popu_rkzs" class="rightBtnList selitem">人口数量</li>            <li id="popu_rkmd" class="rightBtnList">人口密度</li>        </ul>    </li>    <li id="economy" class="rightBtn"><div></div>经济        <ul class="rightBtnUl" style="width: 100px; top: 320px; display: none;">            <li id="eco_gdp" class="rightBtnList selitem">GDP</li>            <li id="eco_czsr" class="rightBtnList">财政收入</li>            <li id="eco_bqx" class="rightBtnList">全国百强县</li>        </ul>    </li>    <li id="picture" class="rightBtn"><div></div>照片        <ul class="rightBtnUl" style=" width: 100px;top:348px;">            <li id="pic_pub" class="rightBtnList selitem"><input style="height: 17px;vertical-align:middle;width:20px;" type="checkbox" checked="checked">聚类显示</li>        </ul>    </li>    <li id="pollution" class="rightBtn"><div></div>污染        <ul class="rightBtnUl" style="width: 100px;top:381px;">            <li id="poll_water" class="rightBtnList selitem">废水</li>            <li id="poll_air" class="rightBtnList">废气</li>            <li id="poll_fac" class="rightBtnList">污水厂</li>       '


            //右侧导航布局
            var str = '<div id="rightWidgetDiv">' +
                '    <div id="rightWidgetDiv">' +
                '        <div id="Rw_top_back">' +
                '            <div id="Rw_top_img"></div>' +
                '            <span id="Top_label"></span>' +
                '        </div>' +
                '        <ul id="Rwidget_ul">' +
                '            <li id="weather" class="rightBtn"><div class=""></div>大网格</li>' +
                //'            <li id="scenic" class="rightBtn"><div class=""></div>大网格</li>' +
                '            <li id="area" class="rightBtn"><div class=""></div>中网格</li>' +
                '            <li id="village" class="rightBtn"><div class=""></div>小网格</li>' +
                '            <li id="road" class="rightBtn"><div class=""></div>矛盾纠纷</li>' +
                //'            <li id="scenic" class="rightBtn"><div></div>景点</li> ' +
                '            <li id="video" class="rightBtn"><div></div>视频监控</li>' +
                '            <li id="enviroment" class="rightBtn">' +
                '                <div class=""></div>数据统计' +
                //'                <ul class="rightBtnUl" style="width: 65px; top: 189px;left:-65px; display: none;">' +
                //'                    <li id="e_station" class="rightBtnList" style="display:none;">空气质量</li>' +
                //'                    <li id="e_city" class="rightBtnList" style="display:none;">区域统计</li>' +
                //'                    <li id="e_contrast" class="rightBtnList selitem">莒县统计图</li>' +
                //'                </ul>' +
                '            </li>' +
                '        </ul>' +
                '    </div>' +
                '</div>';

            k || (h = b, $("#rightWidgetDiv").append(str), $("#rightWidgetDiv .rightBtn").click(function () {
                var a = $(this),
                    b = a.children("div");
                a.hasClass("active") ? (b.removeClass("active"), a.removeClass("active"), a.children("ul").css({
                    display: "none"
                }), a = a.attr("id"), c[a] && c[a].Dispose()) : (b.addClass("active"), a.addClass("active"), a.children("ul").css({
                    display: "block"
                }), l(a.attr("id")))
            }), $("#Rw_top_back").click(function (b) {
                b = $("#Rw_top_img");
                var c = $("#Rwidget_ul"),
                    d = $(this),
                    e = $("#Top_label");
                b.hasClass("hide") ? (d.removeClass("hide"), c.show(500), b.removeClass("hide"), e.html("")) : c.hide(500, a)
            }), $("#rightWidgetDiv .rightBtnList").click(function (a) {
                var b = $(this),
                    d,
                    c;
                d = b.parents(".rightBtn").attr("id");
                "LI" == a.target.tagName ? (c = b.attr("id"), 0 < b.children(":checkbox").length ? b.children(":checkbox")[0].checked ? b.children(":checkbox")[0].checked = !1 : b.children(":checkbox")[0].checked = !0 : b.addClass("selitem").siblings().removeClass("selitem"), l(d, c)) : "INPUT" == a.target.tagName && (c = b.attr("id"), l(d, c));
                a.stopImmediatePropagation()
            }), $(".rightBtn").mouseenter(function (a) {
                a = $(this);
                a.hasClass("active") && a.children("ul").css("display", "block")
            }), $(".rightBtn").mouseleave(function (a) {
                $(this).children("ul").css("display", "none")
            }), c = {
                weather: new WeatherWidget,
                road: new RoadWiget,
                enviroment: new EnvironmentWidget,
                waterq: new WaterQuanlityWidget,
                waterc: new WaterConditionWidget,
                scenic: new ScenicWidget,
                rain: new RainWidget,
                video: new VideoWidget,
                population: new PopulationWidget,
                economy: new EconomicWidget,
                picture: new ImgCluster,
                pollution: new PollutionWidget,
                area: new AreaWidget,
                village: new VillageWidget
            },
                m = new Ol2.StyleMap({
                    fillOpacity: 1,
                    pointRadius: 3
                }), g = Ol2.Util.getParameters(window.location.href).renderer, k = !0)
        },
        reset: function () {
            for (var b in c) c[b] && c[b].isInit() && c[b].Dispose();
            $("#rightWidgetDiv .rightBtn.active").each(function (a, b) {
                $(b).removeClass("active").children().removeClass("active")
            })
        }
    }
}(),
    MapContrast = function () {
        function l(a) {
            q || (u = a, $(window).resize(function () {
                v && c()
            }), q = !0)
        }
        function c() {
            var a = ($("#mapDiv").width() - 2) / (2 * $("#mapDiv").width()) * 100 + "%";
            $("#mapDiv").css("width", a);
            $("#mapDiv1").css("width", a);
            $("#Lc").css("left", $("#mapDiv").width() - 84);
            $("#mapDiv1").css("height", "100%");
            $("#mapDiv1").css("display", "block");
            $("#Lc").css("display", "block");
            $("#Ic").css("display", "block");
            u.map.updateSize();
            null != z && z.map.updateSize()
        }
        function m() {
            J = [new Ol2.Control.DrawFeature(B, Ol2.Handler.RegularPolygon, {
                handlerOptions: {
                    layerOptions: {
                        renderers: void 0,
                        styleMap: H
                    },
                    sides: 4,
                    irregular: !0
                },
                featureAdded: g
            }), new Ol2.Control.DrawFeature(B, Ol2.Handler.RegularPolygon, {
                handlerOptions: {
                    layerOptions: {
                        renderers: void 0,
                        styleMap: H
                    },
                    sides: 50,
                    irregular: !0
                },
                featureAdded: g
            }), new Ol2.Control.DrawFeature(B, Ol2.Handler.Polygon, {
                handlerOptions: {
                    layerOptions: {
                        renderers: void 0,
                        styleMap: H
                    }
                },
                featureAdded: g
            })];
            u.map.addControls(J);
            $(".C_d_mark_li").on("click",
                function () {
                    J[A].deactivate();
                    A = $(this).index();
                    J[A].activate()
                })
        }
        function g(a) {
            D.pointRadius = 24;
            D.fillColor = "#0000ff";
            D.fillOpacity = .1;
            D.strokeWidth = 2;
            D.strokeColor = "#0000ff";
            a.style = Ol2.Util.extend({},
                D);
            B.drawFeature(a);
            J[A].deactivate();
            var b = new Ol2.Feature.Vector;
            b.geometry = a.geometry.clone();
            D.fillColor = "#FC1C02";
            D.strokeColor = "#FC1C02";
            b.style = Ol2.Util.extend({},
                D);
            F.addFeatures(b)
        }
        function h() {
            "d" == $(this)[0].id ? (G = null, $("#d").find("li").removeClass("active"), 0 == C ? ($("#d li:eq(1)").addClass("active"), y(u, "img", !0), C = 1) : ($("#d li:eq(0)").addClass("active"), y(u, "vec", !1), C = 0), f(0, C)) : (I = null, $("#d1").find("li").removeClass("active"), 0 == p ? ($("#d1 li:eq(1)").addClass("active"), y(z, "img", !0), p = 1) : ($("#d1 li:eq(0)").addClass("active"), y(z, "vec", !1), p = 0), f(1, p))
        }
        function k(a) {
            v && null != z && ("mapDiv" == $(this)[0].div.id ? z.map.setCenter(u.map.getCenter(), u.map.getZoom(), !0, !0) : u.map.setCenter(z.map.getCenter(), z.map.getZoom(), !0, !0), d());
            B.redraw();
            F.redraw()
        }
        function b(a) {
            var b = $("#mapDiv").width() + 2;
            "mapDiv" == $(this)[0].div.id ? document.getElementById("Ic").style.left = a.clientX + b - $("#mapDiv").offset().left + "px" : document.getElementById("Ic").style.left = a.clientX - b - $("#mapDiv").offset().left + "px";
            document.getElementById("Ic").style.top = a.clientY + "px"
        }
        function a() {
            u.imgLayer && (u.removeLayer(u.imgLayer), u.imgLayer = null);
            B && B.removeAllFeatures();
            F && F.removeAllFeatures()
        }
        function e() {
            $("#Rwidget_ul li").each(function () {
                $(this).hasClass("active") && $(this).click()
            })
        }
        function f(a, b) {
            var c = 0 == a ? $("#d_radio") : $("#d1_radio");
            1 == b ? d() : c.hide(400)
        }
        function d() {
            var a = u.map.getCenter();
            $.ajax({
                url: Service.IMGMETA + "wktpoint=" + ("POINT(" + a.lon + " " + a.lat + ")") + "&level=" + u.map.zoom,
                success: r,
                dataType: "jsonp"
            })
        }
        function r(a) {
            E = [];
            if (a && 0 < a.length) {
                var b = a;
                b.sort(t);
                for (i = 0; i < b.length; i++) obj = b[i],
                    a = {},
                    a.str = obj.st.toString(),
                    a.grp = obj.lid,
                    E.push(a)
            }
            1 == C && n(0);
            1 == p && n(1)
        }
        function t(a, b) {
            if (a.lid.toString() > b.lid.toString()) return -1;
            if (a.lid.toString() < b.lid.toString()) return 1;
            if (a.lid.toString() == b.lid.toString()) return 0
        }
        function n(a) {
            var b = 0 == a ? $("#d_radio") : $("#d1_radio");
            if (0 < E.length) {
                var d = 0 == a ? $("#d_ul") : $("#d1_ul"),
                    c = 0 == a ? G : I;
                d.find("li").remove();
                b.css("height", 25 * E.length);
                b.show(400);
                for (b = 0; b < E.length; b++) {
                    var e = $("<div class='div_list' ></div>"),
                        f = $("<li class='contrast_li'></li>");
                    f.attr("value", E[b].grp);
                    f.attr("type", a);
                    f.append(e);
                    f.append(E[b].str);
                    f.bind("click", w);
                    d.append(f);
                    0 != b || c ? E[b].grp == c && (e.addClass("active"), f.addClass("active")) : (e.addClass("active"), f.addClass("active"))
                }
            } else b.hide(400)
        }
        function w() {
            var a, b = $(this).attr("value");
            "0" == $(this).attr("type") ? (a = u, G = b, $("#d_ul").children("li").children("div").removeClass("active"), $("#d_ul").children("li").removeClass("active")) : (a = z, I = b, $("#d1_ul").children("li").children("div").removeClass("active"), $("#d1_ul").children("li").removeClass("active"));
            $(this).children("div").addClass("active");
            $(this).addClass("active");
            y(a, b, !0)
        }
        function y(a, b, d) {
            a.imgLayer && (a.removeLayer(a.imgLayer), a.imgLayer = null);
            if ("vec" == b) a.tileLayerManager.switchMap("vec", !0);
            else if ("img" == b) a.tileLayerManager.switchMap("img", !0);
            else {
                a.tileLayerManager.setVisibility("vec", !1);
                a.tileLayerManager.setVisibility("img", !1);
                for (var c in stimgLayerCfg) if (stimgLayerCfg[c].lid == b) {
                    a.imgLayer = new Ol2.Layer.WMTS(stimgLayerCfg[c]);
                    a.addLayer(a.imgLayer);
                    a.map.setLayerIndex(a.imgLayer, 1);
                    break
                }
            }
        }
        var q = !1,
            v = !1,
            u, z, F, B, C = 0,
            p = 0,
            E = [],
            G,
            I,
            A = 0,
            J,
            D = Ol2.Util.extend({},
                Ol2.Feature.Vector.style["default"]),
            H = new Ol2.StyleMap({
                "default": {
                    pointRadius: 24,
                    fillOpacity: .2,
                    graphicWidth: 24,
                    graphicHeight: 24,
                    graphicYOffset: -22,
                    externalGraphic: "../Content/map/images/mark2/point7.png",
                    graphicZIndex: 100,
                    fillColor: "blue",
                    strokeWidth: 1,
                    strokeOpacity: 1,
                    strokeColor: "red",
                    fontColor: "blue",
                    cursor: "pointer"
                }
            });
        return {
            init: l,
            mapDivHandler: c,
            IsStartContrast: function () {
                return v
            },
            startContrast: function (d) {
                q || l(d);
                v ? (z.map.events.unregister("moveend", z.map, k), u.map.events.unregister("moveend", u.map, k), z.map.events.unregister("mousemove", z.map, b), u.map.events.unregister("mousemove", u.map, b), $(".c_list_ul").unbind("click"), $(".C_d_mark_li_clear").unbind("click"), v = !1, $("#vec_").click(), $("#mapDiv").css("width", "100%"), $("#mapDiv1").css("display", "none"), $("#Lc").css("display", "none"), $("#rightWidgetDiv").css("display", "block"), $("#Ic").css("display", "none"), $("#left_hidden").hasClass("show") && $("#left_hidden").click(), $("#vec_img").css("display", "block"), $("#dict").css("display", "block"), $(".C_d_mark").css("display", "none"), $("#btnImgCompare").html("<span class='btnToolbar-cont'><span class='btnToolbar-img' style='background-position: -98px 0;'></span>对比</span>"), $("#btnImgCompare").css("width", "60px"), a(), u.map.updateSize(), ImgMetaCtl && ImgMetaCtl.setActive(!0)) : (isImg = !1, e(), $("#vec_").click(), $("#stImgmetaInfo").css("display", "none"), $("#left_hidden").hasClass("show") || $("#left_hidden").click(), $("#rightWidgetDiv").css("display", "none"), $("#dict").css("display", "none"), $("#btnImgCompare").html("<span class='btnToolbar-cont'><span class='btnToolbar-img' style='background-position: -96px 0;'></span>退出对比</span>"), $("#btnImgCompare").css("width", "86px"), $("#vec_img").css("display", "none"), $(".C_d_mark").css("display", "block"), v = !0, c(), z || (z = new SDMap("mapDiv1", {
                    zoombar: 0,
                    keyboard: !0,
                    layerSwitch: 0,
                    poiIdenty: !1,
                    scaleLine: !1
                })), F || (new Ol2.StyleMap({
                    "default": {
                        fillColor: "#ee9900",
                        pointRadius: 6
                    }
                }), F = new Ol2.Layer.Vector("markers", {
                    style: null
                }), z.map.addLayer(F, !0)), B || (B = new Ol2.Layer.Vector("mark_contrast", {
                    style: null
                }), u.map.addLayer(B, !0), m()), z.map.setCenter(u.map.getCenter(), u.map.getZoom()), z.map.events.register("moveend", z.map, k), u.map.events.register("moveend", u.map, k), z.map.events.register("mousemove", z.map, b), u.map.events.register("mousemove", u.map, b), $(".c_list_ul").bind("click", h), $(".C_d_mark_li_clear").bind("click", a), $("#d li:eq(1)").removeClass("active"), $("#d li:eq(0)").addClass("active"), $("#d_radio").css("display", "none"), p = C = 0, $("#d1").click(), ImgMetaCtl && ImgMetaCtl.setActive(!1))
            }
        }
    }(),
    popup1,
    Bzj = !0,
    TileLayerManager = function () {
        function l() {
            for (var g = h.zoom,
                b = 0; b < c.length; b++) c[b].open && (c[b].maxlevel >= g && c[b].minlevel <= g ? c[b].layer.setVisibility(!0) : c[b].layer.setVisibility(!1))
        }
        var c = [],
            m = [],
            g = 1,
            h = null;
        return {
            setConfig: function (g, b) {
                h = g;
                for (var a = 0; a < b.length; a++) {
                    b[a].open || (b[a].visibility = !1);
                    var e = new Ol2.Layer.WMTS(b[a]);
                    c.push({
                        layer: e,
                        layerid: b[a].layer,
                        group: b[a].group,
                        open: b[a].open,
                        minlevel: b[a].minlevel || 0,
                        maxlevel: b[a].maxlevel || 20
                    });
                    h.addLayer(e)
                }
                g.Lary = c;
                h.events.register("zoomend", this, l)
            },
            switchMap: function (k, b) {
                var a;
                if (null == k) for (a = 0; a < c.length; a++) c[a].group == g + "_n" && (c[a].layer.setVisibility(!!b), c[a].open = !!b);
                else {
                    for (a = 0; a < c.length; a++) b && c[a].group == k + "_n" || c[a].group == k ? (c[a].open = !0, c[a].minlevel <= h.zoom && c[a].maxlevel >= h.zoom && c[a].layer.setVisibility(!0)) : (c[a].open = !1, c[a].layer.setVisibility(!1));
                    g = k
                }
                for (a = 0; a < m.length; a++) m[a](g)
            },
            setVisibility: function (g, b) {
                for (i = 0; i < c.length; i++) c[i].group == g && (c[i].layer.setVisibility(!!b), c[i].open = !!b)
            },
            addListener: function (c) {
                "function" == typeof c && m.push(c)
            },
            removeListener: function (c) {
                "function" == typeof c && (c = m.find(function (b) {
                    return b === this
                }), m.splice(c, 1))
            },
            getLayer: function (g) {
                var b;
                if (g.group) {
                    var a = [];
                    for (b = 0; b < c.length; b++) c[b].group == g.group && a.push(c[b].layer);
                    return a
                }
                if (g.layer) for (b = 0; b < c.length; b++) if (c[b].layerid == g.layer) return c[b].layer
            },
            getLayers: function () {
                return c
            }
        }
    },
    SDMap = function (l, c) {
        function m() {
            $(k.div).append("<div id='refrenceDiv'></div>");
            c.layerSwitch2 && k.addControl(new Ol2.Control.LayerSwitcher);
            c.scaleLine && k.addControl(new Ol2.Control.ScaleLine({
                maxWidth: 200,
                topOutUnits: "千米",
                topInUnits: "米",
                bottomOutUnits: "",
                bottomInUnits: ""
            }));
            1 == c.zoombar ? k.addControl(new Ol2.Control.PanZoomBar) : 2 == c.zoombar && k.addControl(new Ol2.Control.Zoom);
            c.keyboard && k.addControl(new Ol2.Control.KeyboardDefaults);
            e = new Ol2.Control.SelectFeature([b]);
            e.handlers.feature.stopDown = !1;
            e.handlers.feature.stopUp = !1;
            k.addControl(e);
            e.activate();
            var a = new Ol2.Control.Navigation({
                dragPanOptions: {
                    enableKinetic: !0,
                    documentDrag: !1,
                    kineticInterval: 10
                },
                zoomWheelEnabled: !0,
                handleRightClicks: !1
            });
            k.addControl(a);
            c.mousePosition && h();
            c.authMark && $("#refrenceDiv").before("<div id ='bottomBar'></div><div id ='remark'>审图号:GS(2017)508号(版权:国家测绘地理信息局) 鲁SG(2017)040号(版权:山东省国土资源厅)</div>");
            1 == c.layerSwitch ? ($(k.div).append($("<style> #layerSwitch:hover{border: 1px solid #2D9FBB;}</style><div id='layerSwitch'style='position: absolute;top:3px;width: 50px;height: 50px;right:3px;z-index: 1001;border:1px solid #DEE1E2;font-size:12px;background:url(../Content/map/images/map/img1.png)'></div>")), $("#layerSwitch").click(function () {
                var a = $(this);
                a.css("background-image").match(/(img1.png)/) ? (f.switchMap(2, !0), a.css("background-image", "url(../Content/map/images/map/vec1.png)"), g("white")) : (f.switchMap(1), a.css("background-image", "url(../Content/map/images/map/img1.png)"), g("black"))
            })) : 2 == c.layerSwitch && ($(k.div).append($("<div id='layerSwitch'style='position: absolute;bottom:10px;right: 20px;z-index: 1001;font-size:12px'><div class='operbtn mapswitchbtn'>矢量</div><div class='operbtn mapswitchbtn' style='background-color:#b2b2b2'>影像</div></div>")), $("#layerSwitch .mapswitchbtn").click(function () {
                var a = $(this);
                "矢量" == a.text() ? (f.switchMap(1), g("black")) : (f.switchMap(2, !0), g("white"));
                a.removeAttr("style").siblings().css("background-color", "#b2b2b2")
            }))
        }
        function g(a) {
            $("#img_year_div").show();
            $(".olControlScaleLineTop").css({
                border: "solid 2px " + a,
                "border-top": "none",
                color: a
            });
            $(".olControlScaleLineBottom").css({
                border: "solid 2px " + a,
                "border-bottom": "none",
                color: a
            })
        }
        function h() {
            $("#refrenceDiv").before("<div id = 'mousePositon'></div>");
            $(".olMapViewport").mousemove(function (a) {
                var b = $(this).offset();
                a = new Ol2.Pixel(a.clientX - b.left, a.clientY - b.top);
                a = k.getLonLatFromPixel(a);
                $("#mousePositon").text("经度:" + a.lon.toFixed(3) + ", 纬度:" + a.lat.toFixed(3))
            })
        }
        var k = null,
            b = null,
            a, e, f = new TileLayerManager;
        c || (c = {});
        Ol2.Util.applyDefaults(c, {
            scaleLine: !0,
            zoombar: 1,
            keyboard: !0,
            mousePosition: !0,
            poiIdenty: !1,
            authMark: !0,
            layerSwitch: 1,
            layerSwitch2: !1
        });
        Ol2.INCHES_PER_UNIT["千米"] = Ol2.INCHES_PER_UNIT.km;
        Ol2.INCHES_PER_UNIT["米"] = Ol2.INCHES_PER_UNIT.m;
        Ol2.INCHES_PER_UNIT["英里"] = Ol2.INCHES_PER_UNIT.mi;
        Ol2.INCHES_PER_UNIT["英尺"] = Ol2.INCHES_PER_UNIT.ft; (function (d) {
            Ol2.DOTS_PER_INCH = 96;
            k = new Ol2.Map(d, {
                allOverlays: !0,
                numZoomLevels: 19,
                displayProjection: "EPSG:4490",
                controls: [new Ol2.Control.ArgParser, new Ol2.Control.Attribution]
            });
            f.setConfig(k, Service.basemap);
            c.poiIdenty && (k.poiMrk = new Ol2.Ex.PoiMarker(k, f.getLayer({
                layer: "sdvec"
            }), Service.POITILE));
            d = new Ol2.StyleMap({
                fillOpacity: 1,
                pointRadius: 2
            });
            b = new Ol2.Layer.Vector("SelectableLayer", {
                styleMap: d,
                rendererOptions: {
                    zIndexing: !1
                }
            });
            k.addLayer(b);
            a = new Ol2.Layer.Vector("GraphicsLayer", {
                styleMap: d,
                rendererOptions: {
                    zIndexing: !1
                }
            });
            k.addLayer(a);
            m();
            k.setCenter(new Ol2.LonLat(118.9, 35.6), 13)
        })(l);
        return {
            map: k,
            tileLayerManager: f,
            markLayer: b,
            graLayer: a,
            unSelect: function () {
                e.unselectAll()
            },
            addLayer: function (a, b) {
                k.addLayer(a);
                b && e.setLayer(e.layers.concat([a]))
            },
            removeLayer: function (a, b) {
                k.removeLayer(a);
                if (b) for (var c = 0; c < e.layers.length; c++) if (e.layers[c].id == a.id) {
                    var d = e.layers;
                    d.splice(c, 1);
                    e.setLayer(d);
                    break
                }
            },
            getSelectCtrl: function () {
                return e
            },
            addPopup: function (a) {
                a && k.addPopup(a)
            },
            removePopup: function (a) {
                if (a) k.removePopup(a);
                else {
                    a = k.popups;
                    for (var b in a) k.removePopup(a[b])
                }
            }
        }
    };
window.Util || (window.Util = {});
window.Util.HighlightGeo || (window.Util.HighlightGeo = function (l, c) {
    if (l && c) {
        var m = Ol2.Util.applyDefaults({
            fillColor: "#f00",
            fillOpacity: .6,
            strokColor: "#f00",
            strokeWidth: 4,
            pointRadius: 4
        },
            Ol2.Feature.Vector.style["default"]);
        Ol2.Util.isArray(c) || (c = [c]);
        for (var g = [], h = 0; h < c.length; h++) c[h].geometry ? g.push(new Ol2.Feature.Vector(c[h].geometry, null, m)) : g.push(new Ol2.Feature.Vector(c[h], null, m));
        var k = setInterval(function () {
            if (1 == b || 3 == b) m.fillColor = "#0f0",
                m.strokeColor = "#0f0",
                l.redraw(),
                b += 1;
            else if (2 == b || 4 == b) m.fillColor = "#f00",
                m.strokeColor = "#f00",
                l.redraw(),
                b += 1;
            else {
                clearTimeout(k);
                for (var a = 0; a < g.length; a++) g[a].style = null;
                l.redraw()
            }
        },
            500),
            h = (c[0].geometry || c[0]).CLASS_NAME;
        h.match(/Point/) ? (m.strokeWidth = 2, m.pointRadius = 8, m.fillOpacity = 1) : h.match(/LineString/) && (m.strokeWidth = 6, m.fillOpacity = 1);
        l.addFeatures(g);
        var b = 1
    }
});
var DPR_LNG = 6378140 * Math.PI / 180,
    DPR_C = .80385;
function interopGeoSeg(l, c) {
    var m = [],
        g = 0;
    c /= DPR_LNG;
    m.push(l[0]);
    for (var h = 0; h < l.length - 1; h++) {
        var k = l[h].x - l[h + 1].x,
            b = l[h].y - l[h + 1].y,
            a = k * DPR_C,
            e = Math.sqrt(a * a + b * b);
        0 != g && (e += g, g = 0);
        a = e / c;
        a = Math.round(a);
        if (0 == a) g += e;
        else {
            for (var f, d = 1; d < a; d++) e = l[h].x - k / a * d,
                f = l[h].y - b / a * d,
                m.push(new Ol2.Geometry.Point(e, f));
            m.push(l[h + 1])
        }
    }
    return m
}
function interopGeoSeg2(l, c) {
    var m = [],
        g = 0;
    c /= DPR_LNG;
    for (var h = 0; h < l.length - 1; h++) {
        var k = l[h].x - l[h + 1].x,
            b = l[h].y - l[h + 1].y,
            a = k * DPR_C,
            e = Math.sqrt(a * a + b * b);
        0 != g && (e += g, g = 0);
        a = e / c;
        a = Math.round(a);
        if (0 == a) g += e;
        else {
            for (var f, d = [], r = 1; r < a; r++) e = l[h].x - k / a * r,
                f = l[h].y - b / a * r,
                d.push(new Ol2.Geometry.Point(e, f));
            d.push(l[h + 1]);
            m.push({
                idx: h,
                seg: d
            })
        }
    }
    return m
}
function DrawFlowPath(l, c, m) {
    var g = l.getGeodesicLength();
    m || (m = 1E3 > g ? 2E3 : 1E4 > g ? 3E3 : 4E3);
    m = 40 * g / m;
    var h = l.getVertices(),
        k = interopGeoSeg2(h, m),
        b = Ol2.Util.extend({},
            Ol2.Feature.Vector.style["default"]);
    b.strokeColor = "#f00";
    b.strokeOpacity = 1;
    b.strokeWidth = 5;
    var a = k.length,
        e = 0,
        f = 1,
        d, r = [],
        t = setInterval(function () {
            e == a ? (clearInterval(t), c.removeFeatures(d)) : d ? f == k[e].seg.length ? (e++ , r = e != a ? h.slice(0, k[e].idx) : h, c.removeFeatures(d), d = new Ol2.Feature.Vector(new Ol2.Geometry.LineString(r), null, b), c.addFeatures(d), f = 0) : (d.geometry.addPoint(k[e].seg[f]), f++ , c.redraw()) : (d = new Ol2.Feature.Vector(new Ol2.Geometry.LineString([k[e].seg[0]]), null, b), c.addFeatures(d))
        },
            10)
}
var sdMap, g_userid = g_userid || "",
    g_username = g_username || "",
    isImg = !1;
var graphicLayer;
function initPage() {
    sdMap = new SDMap("mapDiv", {
        scaleLine: !0,
        keyboard: !0,
        layerSwitch: 0,
        mousePosition: !0,
        poiIdenty: !0
    });
    MapToolUI.init(sdMap);
    RightMenu.init(sdMap);
    PoiInfoPop.init(sdMap);
    WidgetManger.init(sdMap);
    PathSearch.init(sdMap);
    WholeSearch.init(sdMap);
    ImgMetaCtl.init(Service.IMGMETA, sdMap);
    g_userid = getCookie("USERID") || "0";
    g_username = getCookie("USERNAME") || "游客"





} (function () {
    Browser.ie6 || Browser.ie6Compat || Browser.ie7 || Browser.ie7Compat ? (alert("当前使用ie内核版本太低,部分功能将无法使用，建议使用IE8及以上版本浏览器！"), parent.window.document.getElementById("iframe_").src = "map/ie6.html") : initProject()

    //定位到莒县
    setTimeout(showjxRegion, 1000);
    setTimeout(OpenXingzheng, 1000);

})();

//显示轨迹
function showGuiJi(id) {

    //创建矢量图层
    graphicLayer = new OpenLayers.Layer.Vector("graphicLayer", { style: OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']) });
    sdMap.map.addLayer(graphicLayer);

    var style = {
        strokeColor: "#ff0000",
        strokeWidth: 4,
        fontColor: "#ff00ff"
    };

    $.ajax({
        type: "POST",
        url: "/Home/GetUserTrajectoryByUserId",
        contentType: "application/json",
        data: JSON.stringify({ userId: id }),
        dataType: "json",
        success: function (res) {
            var data = res.result;
            var arr = [];
            for (var i = 0; i < data.length; i++) {
                arr.push(new OpenLayers.Geometry.Point(data[i].latitude, data[i].longitude));
                if (i == 0) {
                    var startPoint = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(data[i].latitude, data[i].longitude), null,
                        {
                            externalGraphic: '../Content/map/images/path/start.png', graphicWidth: 23, graphicHeight: 25
                        });
                    graphicLayer.addFeatures(startPoint);
                }
                if (i == data.length - 1) {
                    var endPoint = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(data[i].latitude, data[i].longitude), null,
                        {
                            externalGraphic: '../Content/map/images/path/end.png', graphicWidth: 23, graphicHeight: 25
                        });
                    graphicLayer.addFeatures(endPoint);
                }
            }

            //构造线  
            var line = new OpenLayers.Geometry.LineString(arr);
            var feature = new OpenLayers.Feature.Vector(line, null, style);
            graphicLayer.addFeatures([feature]);
        },
        error: function (a, b) {
            console.log && console.log("数据请求" + b)
        }
    });


    //---------------------------------------------------------------------

    ////定义地图对象
    //var graphic; var moving; var polylineJson; var points;

    ////创建矢量图层
    //var graphicLayer = new OpenLayers.Layer.Vector("graphicLayer", { style: OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']) });
    //sdMap.addLayer(graphicLayer);



    //var line = new OpenLayers.Geometry.LineString([
    //    OpenLayers.Geometry.Point(116.895, 36.6513),
    //    OpenLayers.Geometry.Point(116.972, 36.773),
    //    OpenLayers.Geometry.Point(117.089212, 36.65343),
    //    OpenLayers.Geometry.Point(117.466312, 36.73743)
    //]);

    //var style = {
    //    strokeColor: "#00ff00",
    //    strokeWidth: 2,
    //    strokeDashstyle: "dash"
    //};

    //var feature = new OpenLayers.Feature.Vector(line, null, style);
    //graphicLayer.addFeatures([feature]);



    //var graphic = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(116.895, 36.6513), null,
    //    { externalGraphic: 'http://www.sdmap.gov.cn/api/olapi/images/car.png', graphicWidth: 25, graphicHeight: 51 });

    //graphicLayer.addFeatures(graphic);


    //document.getElementById("openTool").onclick = function () {
    //    points = line.getVertices();
    //    graphic.geometry.x = points[0].x;
    //    graphic.geometry.y = points[0].y;
    //    graphicLayer.redraw();

    //    move(0, 1);
    //};

    //document.getElementById("closeTool").onclick = function () {
    //    clearInterval(moving);
    //};



    ////根据序列点坐标 进行移动
    //function move(start, end) {
    //    var x1 = points[start].x;
    //    var y1 = points[start].y;
    //    var x2 = points[end].x;
    //    var y2 = points[end].y;


    //    var p = (y2 - y1) / (x2 - x1); //斜率
    //    var v = 0.01; //速度

    //    moving = setInterval(function () {

    //        //分别计算 x,y轴方向速度
    //        if (Math.abs(p) == Number.POSITIVE_INFINITY) //无穷大
    //            graphic.geometry.y += v;
    //        else {
    //            graphic.geometry.x += (1 / Math.sqrt(1 + p * p)) * v;
    //            graphic.geometry.y += (p / Math.sqrt(1 + p * p)) * v;
    //        }

    //        //计算汽车角度
    //        graphic.style.rotation = (Math.PI / 2 - Math.atan(p)) * 180 / Math.PI;
    //        //图层刷新
    //        //  map.graphics.redraw();



    //        graphicLayer.redraw();

    //        if (Math.abs(graphic.geometry.x - x2) < 0.01 && Math.abs(graphic.geometry.y - y2) < 0.01) {
    //            clearInterval(moving);
    //            start++;
    //            end++;

    //            if (end < points.length)
    //                move(start, end);
    //        }
    //    }, 50);
    //}

}

function showjxRegion() {
    $("#cityTable td:last").click()
}
function OpenXingzheng() {
    $("#btnxinzheng").click();
}
function initProject() {
    $(function () {
        $("#mapDiv").css("width", "100%");
        $("#tab_search").click(function (l) {
            $(this).css({
                backgroundPosition: "0 -46px"
            });
            $("#tab_gps").css({
                backgroundPosition: "-400px -46px"
            });
            $("#tab_resource").css({
                backgroundPosition: "-498px -46px"
            });
            switchSearch("s1")
        });
        $("#tab_gps").click(function (l) {
            $("#tab_search").css({
                backgroundPosition: "-300px -46px"
            });
            $(this).css({
                backgroundPosition: "-100px -46px"
            });
            $("#tab_resource").css({
                backgroundPosition: "-498px -46px"
            });
            switchSearch("s3")
        });
        $("#tab_resource").click(function (l) {
            $("#tab_search").css({
                backgroundPosition: "-300px -46px"
            });
            $("#tab_gps").css({
                backgroundPosition: "-400px -46px"
            });
            $(this).css({
                backgroundPosition: "-200px -46px"
            });
            switchSearch("s4")
        });

        //隐藏左侧菜单 申国强
        $("#left_hidden").css("display", "block");
        $("#left").css("display", "block");
        //$("#center").css({
        //    width: $(window).width(),
        //    left: 0
        //}).attr("data-calc-width", "100%-0px");

        $("#left_hidden").click(function (l) {
            $(this).hasClass("show") ? ($(this).removeClass("show"), $(this).attr({
                title: "收起左栏"
            }), $("#left").css("display", "block"), $("#center").css({
                width: $(window).width() - 304,
                left: 304
            }).attr("data-calc-width", "100%-304px")) : ($(this).addClass("show"), $(this).attr({
                title: "展开左栏"
            }), $("#left").css("display", "none"), $("#center").css({
                width: $(window).width(),
                left: 0
            }).attr("data-calc-width", "100%-0px"));
            MapContrast.IsStartContrast() ? MapContrast.mapDivHandler() : sdMap.map.updateSize()
        });
        initPage()
    })
}
function switchSearch(l) {
    "s3" == l ? ($("#tab_gps_div").css("display", "block").siblings(":gt(2)").css("display", "none"), $("#tab_gps_div").css("display", "block").siblings(":gt(3)").css("display", "none"), WholeSearch.clearResult()) : "s4" == l ? ($("#tab_resource_div").css("display", "block").siblings(":gt(2)").css("display", "none"), $("#tab_resource_div").css("display", "block").siblings(":gt(3)").css("display", "none"), ResourceList.init(sdMap.map), PathSearch.clearResult(), WholeSearch.clearResult()) : ($("#tab_search_cont").css("display", "block").siblings(":gt(2)").css("display", "none"), $("#tab_search_cont").css("display", "block").siblings(":gt(3)").css("display", "none"), "s1" == l ? $("#tab_search_div1").css("display", "block").siblings(":gt(0)").css("display", "none") : $("#tab_search_div2").css("display", "block").siblings(":gt(0)").css("display", "none"), PathSearch.clearResult())
};

//显示统计信息
(function () {
    $("#enviroment").click(function () {
        $("#env_HistFrame").css("display", "block").find("iframe").attr("src", "EnvCityStatistic")
    });
})();


Date.prototype.Format = function (fmt) { //author: meizz 
    var o = {
        "M+": this.getMonth() + 1, //月份 
        "d+": this.getDate(), //日 
        "h+": this.getHours(), //小时 
        "m+": this.getMinutes(), //分 
        "s+": this.getSeconds(), //秒 
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
        "S": this.getMilliseconds() //毫秒 
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}




//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

var gWndId = 0;
var nDirect = -1;
var nOper = -1;
var gXmlRecords;
var gRecordPath;
var bLogin = 0;
var bIVS = 1;

//function switchTab(n)
//{
//	for(var i=1;i<=10;i++)
//	{
//		document.getElementById("tab_" + i).className = "";
//		document.getElementById("tab_con_" + i).style.display = "none";
//	}
//	document.getElementById("tab_" + n).className = "on";
//	document.getElementById("tab_con_" + n).style.display = "block";
//	document.getElementById("DGroupInfo").innerText = "";
//}

function historyRealplay(cameraId) {
    var obj = document.getElementById("DPSDK_OCX");

    var szCameraId = cameraId;
    var nStreamType = document.getElementById("selectStreamType").value;
    var nMediaType = document.getElementById("selectMediaType").value;
    var nTransType = document.getElementById("selectTransType").value;

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var nRet = obj.DPSDK_StartRealplayByWndNo(gWndId, nWndNo, szCameraId, nStreamType, nMediaType, nTransType);
    ShowCallRetInfo(nRet, "播放视频");
    if (nRet == 0) {
        ShowCallRetInfo(obj.DPSDK_SetIvsShowFlagByWndNo(gWndId, nWndNo, 1, bIVS), "规则线显示");//打开规则线显示
        ShowCallRetInfo(obj.DPSDK_SetIvsShowFlagByWndNo(gWndId, nWndNo, 2, bIVS), "目标框显示");//打开目标框显示
        ShowCallRetInfo(obj.DPSDK_SetIvsShowFlagByWndNo(gWndId, nWndNo, 3, bIVS), "轨迹线显示");//打开轨迹线显示
    }
}

//function insertRealplayHistory(cameraId) 
//{
//	var eleTr = document.createElement("tr");

//	var eleTdCameraId = document.createElement("td");
//	eleTdCameraId.innerHTML = cameraId;
//	eleTr.appendChild(eleTdCameraId);

//	var eleTdBtn = document.createElement("td");
//	var eleBtn = document.createElement("button");
//	eleBtn.innerHTML = "播放";
//	eleTdBtn.appendChild(eleBtn);
//	eleTr.appendChild(eleTdBtn);

//	eleTdBtn.onclick = function() {
//	historyRealplay(cameraId);
//	};

//	eleTr.ondblclick = function() {
//	historyRealplay(cameraId);
//	};

//	document.getElementById("historyContent").appendChild(eleTr);
//}

function getStrLength(str) {
    var cArr = str.match(/[^\x00-\xff]/ig);
    return str.length + (cArr == null ? 0 : cArr.length);
}

function monitorInit() {
    //switchTab(1);

	/*try
	{
		var obj = new ActiveXObject("DPSDK_OCX.DPSDK_OCXCtrl.1");
	}
	catch(e)
	{
		alert("控件未注册，请先注册控件！");
		return;
	}*/

    var obj = document.getElementById("DPSDK_OCX");
    gWndId = obj.DPSDK_CreateSmartWnd(0, 0, 100, 100);

    ButtonCreateWnd_onclick();
    //obj.DPSDK_SetLog(2, "D:\\DPSDK_OCX_log", false, false); //初始化后设置日志路径
    //var obj = document.getElementById("DPSDK_OCX");
    //ShowCallRetInfo(obj.DPSDK_Login("172.7.123.123", 9000, "1", "1"), "登录");
    //ShowCallRetInfo(obj.DPSDK_AsyncLoadDGroupInfo(), "异步加载组织结构");
    //var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    //ShowCallRetInfo(obj.DPSDK_DirectRealplayByWndNo(gWndId, nWndNo, "1000001$1$0$0", 1, 1, 1), "直接实时播放");
    for (var i = 1; i <= 4; i++)
        obj.DPSDK_SetToolBtnVisible(i, false);
    obj.DPSDK_SetToolBtnVisible(7, false);
    obj.DPSDK_SetToolBtnVisible(9, false);
    obj.DPSDK_SetControlButtonShowMode(1, 0);
    obj.DPSDK_SetControlButtonShowMode(2, 0);

    //登录
    ButtonLogin_onclick();
}
function SetLog() {
    var obj = document.getElementById("DPSDK_OCX");
    var fileSave = new ActiveXObject("MSComDlg.CommonDialog");
    fileSave.MaxFileSize = 128;
    fileSave.ShowSave();
    if (fileSave.fileName == "")
        return -1;
    return obj.DPSDK_SetLog(4, fileSave.fileName, true, true);
}

function GetGps() {
    var obj = document.getElementById("DPSDK_OCX");
    alert(obj.DPSDK_AskForLastGpsStatus());
}

function SetControlButtonShowMode() {
    var obj = document.getElementById("DPSDK_OCX");
    var nType = document.getElementById("textType").value;
    var nMode = document.getElementById("textMode").value;
    obj.DPSDK_SetControlButtonShowMode(nType, nMode);
}
//function ShowCallRetInfo(nRet, strInfo) 
//{
//    //if (nRet != 0)
//    //{
//    //    var obj = document.getElementById("DPSDK_OCX");
//    //    alert(strInfo + ": ErrorCode = "+obj.DPSDK_GetLastError());
//    //}

//	var str = "";
//	if(nRet == 0)
//	{
//	     str = strInfo + " 成功！";
//	}
//	else
//	{
//	     str = strInfo + "失败！错误码：" + nRet;
//		 if(nRet == 19 || nRet == 20)
//		 {
//			str += "，请先加载组织结构！";
//		 }
//	}
//	document.getElementById("RetInfo").innerText = str;
//}
function getDate(strDate) {
    var date = eval('new Date(' + strDate.replace(/\d+(?=-[^-]+$)/,
        function (a) { return parseInt(a, 10) - 1; }).match(/\d+/g) + ')');
    return date;
}

function ButtonCreateWnd_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndCount = "1";
    obj.DPSDK_SetWndCount(gWndId, nWndCount);
    obj.DPSDK_SetSelWnd(gWndId, 0);
}

function ButtonSetCustomizedWndCount_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndCount = "1";
    obj.DPSDK_SetCustomizedWndCount(gWndId, nWndCount);
    obj.DPSDK_SetSelWnd(gWndId, 0);
}

function ButtonLogin_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var szIp = "61.162.225.227";
    var nPort = "9000";
    var szUsername = "admin";
    var szPassword = "admin123";

    var nRet = obj.DPSDK_Login(szIp, nPort, szUsername, szPassword);
    //ShowCallRetInfo(nRet, "登录");
    if (nRet == 0) {
        bLogin = 1;
    }
    //ButtonLoadDGroupInfo_onclick();

}

function ButtonAsyncLogin_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var szIp = document.getElementById("textIP").value;
    var nPort = document.getElementById("textPort").value;
    var szUsername = document.getElementById("textUser").value;
    var szPassword = document.getElementById("textPassword").value;

    var nRet = obj.DPSDK_AsyncLogin(szIp, nPort, szUsername, szPassword);
    if (nRet != 0) {
        ShowCallRetInfo(nRet, "异步登录");
    }
}

function ButtonLogout_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    if (bLogin == 1) {
        //ShowCallRetInfo(obj.DPSDK_Logout(), "登出");
        bLogin = 0;
    }
}


function ButtonLoadDGroupInfo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    ShowCallRetInfo(obj.DPSDK_LoadDGroupInfo(), "加载组织结构");
    //alert(obj.DPSDK_GetDGroupStr());
    //document.getElementById("DGroupInfo").innerText = obj.DPSDK_GetDGroupStr();
}

function ButtonAsyncLoadDGroupInfo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    obj.DPSDK_SetCompressType(1);
    ShowCallRetInfo(obj.DPSDK_AsyncLoadDGroupInfo(), "异步加载组织结构");
    //alert(obj.DPSDK_GetDGroupStr());
}
function ButtonGetDGroupInfo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    document.getElementById("DGroupInfo").innerText = obj.DPSDK_GetDGroupStr();
}

function ButtonConnectDmsByChnlId_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var szCameraId = document.getElementById("textCameraID").value;
    var nRet = obj.DPSDK_ConnectDmsByChnlId(szCameraId);
    ShowCallRetInfo(nRet, "根据通道ID连接DMS");
}

function ButtonStartRealplayByWndNo_onclick(_szCameraId) {
    var obj = document.getElementById("DPSDK_OCX");

    var szCameraId = _szCameraId;
    var nStreamType = "1";//1:TCP、0：UDP
    var nMediaType = "1";//1：主码流、2：辅码流
    var nTransType = "1";//1：视频、2：音频、3：视频 + 音频

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var nRet = obj.DPSDK_StartRealplayByWndNo(gWndId, nWndNo, szCameraId, nStreamType, nMediaType, nTransType);
    //ShowCallRetInfo(nRet, "播放视频");
    //if (nRet == 0) {
    //    //insertRealplayHistory(szCameraId);
    //    ShowCallRetInfo(obj.DPSDK_SetIvsShowFlagByWndNo(gWndId, nWndNo, 1, bIVS), "规则线显示");//打开规则线显示
    //    ShowCallRetInfo(obj.DPSDK_SetIvsShowFlagByWndNo(gWndId, nWndNo, 2, bIVS), "目标框显示");//打开目标框显示
    //    ShowCallRetInfo(obj.DPSDK_SetIvsShowFlagByWndNo(gWndId, nWndNo, 3, bIVS), "轨迹线显示");//打开轨迹线显示
    //}
}

function ButtonAsyncStartRealplayByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var szCameraId = document.getElementById("textCameraID").value;
    var nStreamType = document.getElementById("selectStreamType").value;
    var nMediaType = document.getElementById("selectMediaType").value;
    var nTransType = document.getElementById("selectTransType").value;

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var nRealFlag = obj.DPSDK_AsyncStartRealplayByWndNo(gWndId, nWndNo, szCameraId, nStreamType, nMediaType, nTransType);
    //ShowCallRetInfo(nRet, "播放视频");
    //if(nRet == 0)
    //{
    //	insertRealplayHistory(szCameraId);
    //	ShowCallRetInfo(obj.DPSDK_SetIvsShowFlagByWndNo(gWndId, nWndNo, 1, bIVS),"规则线显示");//打开规则线显示
    //	ShowCallRetInfo(obj.DPSDK_SetIvsShowFlagByWndNo(gWndId, nWndNo, 2, bIVS),"目标框显示");//打开目标框显示
    //	ShowCallRetInfo(obj.DPSDK_SetIvsShowFlagByWndNo(gWndId, nWndNo, 3, bIVS),"轨迹线显示");//打开轨迹线显示
    //}
}

function ButtonStartRealplayByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    var szCameraId = document.getElementById("textCameraID").value;
    var nStreamType = document.getElementById("selectStreamType").value;
    var nMediaType = document.getElementById("selectMediaType").value;
    var nTransType = document.getElementById("selectTransType").value;

    var nRet = obj.DPSDK_StartRealplayByHWND(hWnd, szCameraId, nStreamType, nMediaType, nTransType);
    ShowCallRetInfo(nRet, "播放视频");
    if (nRet == 0) {
        insertRealplayHistory(szCameraId);
        ShowCallRetInfo(obj.DPSDK_SetIvsShowFlagByHWND(hWnd, 1, 1), "规则线显示");//打开规则线显示
        ShowCallRetInfo(obj.DPSDK_SetIvsShowFlagByHWND(hWnd, 2, 1), "目标框显示");//打开目标框显示
        ShowCallRetInfo(obj.DPSDK_SetIvsShowFlagByHWND(hWnd, 3, 1), "轨迹线显示");//打开轨迹线显示
    }
}

function ButtonStopRealplayByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    ShowCallRetInfo(obj.DPSDK_StopRealplayByWndNo(gWndId, nWndNo), "停止播放视频");
}

function ButtonAsyncStopRealplayByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    obj.DPSDK_AsyncStopRealplayByWndNo(gWndId, nWndNo);
}

function ButtonStopRealplayByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    ShowCallRetInfo(obj.DPSDK_StopRealplayByHWND(hWnd), "停止播放视频");
}

function ButtonStartRecordByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var mydate = new Date();
    var reg = new RegExp(":", "g");
    var path = "c:\\dahuaVideo\\" + mydate.toLocaleString().replace(" ", "").replace("年", "").replace("月", "").replace("日", "").replace(reg, "") + ".dav";
    alert("存储路径：" + path)

    ShowCallRetInfo(obj.DPSDK_StartRealRecordByWndNo(gWndId, nWndNo, path), "实时视频录制");
}

function ButtonStartRecordByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    var mydate = new Date();
    var reg = new RegExp(":", "g");
    var path = "c:\\dahuaVideo\\" + mydate.toLocaleString().replace(" ", "").replace("年", "").replace("月", "").replace("日", "").replace(reg, "") + ".dav";
    alert("存储路径：" + path)

    ShowCallRetInfo(obj.DPSDK_StartRealRecordByHWND(hWnd, path), "实时视频录制");
}

function ButtonStopRecordByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    ShowCallRetInfo(obj.DPSDK_StopRealRecordByWndNo(gWndId, nWndNo), "停止实时视频录制");
}

function ButtonStopRecordByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    ShowCallRetInfo(obj.DPSDK_StopRealRecordByHWND(hWnd), "停止实时视频录制");
}

function ButtonSetOsdTxtByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var strOSD = document.getElementById("text7").value;
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    ShowCallRetInfo(obj.DPSDK_SetOsdTxtByHWND(hWnd, strOSD), "OSD文本信息下发");
}

function ButtonCleanUpOsdInfoByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    ShowCallRetInfo(obj.DPSDK_CleanUpOsdInfoByWndNo(gWndId, nWndNo), "清除osd信息");
}

function ButtonCleanUpOsdInfoByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    ShowCallRetInfo(obj.DPSDK_CleanUpOsdInfoByHWND(hWnd), "清除osd信息");
}

function ButtonCapturePictureByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var mydate = new Date();
    var reg = new RegExp(":", "g");
    var path = "c:\\dahuaphoto\\" + mydate.toLocaleString().replace(" ", "").replace("年", "").replace("月", "").replace("日", "").replace(reg, "") + ".bmp";
    alert("存储路径：" + path)
    ShowCallRetInfo(obj.DPSDK_CapturePictureByWndNo(gWndId, nWndNo, path), "抓图");
}

function ButtonCapturePictureByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    var mydate = new Date();
    var reg = new RegExp(":", "g");
    var path = "c:\\dahuaphoto\\" + mydate.toLocaleString().replace(" ", "").replace("年", "").replace("月", "").replace("日", "").replace(reg, "") + ".bmp";
    alert("存储路径：" + path)

    ShowCallRetInfo(obj.DPSDK_CapturePictureByHWND(hWnd, path), "抓图");
}

function ButtonCapturePictureByWndNoAndUpload_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var mydate = new Date();
    var reg = new RegExp(":", "g");
    var path = "c:\\dahuaphoto\\" + mydate.toLocaleString().replace(" ", "").replace("年", "").replace("月", "").replace("日", "").replace(reg, "") + ".bmp";
    alert("存储路径：" + path)
    ShowCallRetInfo(obj.DPSDK_CapturePictureByWndNo(gWndId, nWndNo, path), "抓图");

    var szCameraId = document.getElementById("textCameraID").value;
    var szIp = document.getElementById("textFtpIp").value;
    var szName = document.getElementById("textFtpName").value;
    var szPwd = document.getElementById("textFtpPwd").value;
    var timestamp = Date.parse(new Date()) / 1000;
    var nRet = obj.DPSDK_UploadFtpPic(szCameraId, timestamp, path, "ftp://" + szIp, szName, szPwd);
    if (nRet != 0)
        ShowCallRetInfo(nRet, "上传");
    else {
        var szFtpUrl = obj.DPSDK_GetLastUploadFtpPicUrl();
        alert("已上传至：" + szFtpUrl);
    }
}

function ButtonCapturePictureByHWNDAndUpload_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    var mydate = new Date();
    var reg = new RegExp(":", "g");
    var path = "c:\\dahuaphoto\\" + mydate.toLocaleString().replace(" ", "").replace("年", "").replace("月", "").replace("日", "").replace(reg, "") + ".bmp";
    alert("存储路径：" + path)
    ShowCallRetInfo(obj.DPSDK_CapturePictureByHWND(hWnd, path), "抓图");

    var szCameraId = document.getElementById("textCameraID").value;
    var szIp = document.getElementById("textFtpIp").value;
    var szName = document.getElementById("textFtpName").value;
    var szPwd = document.getElementById("textFtpPwd").value;
    var timestamp = Date.parse(new Date()) / 1000;
    var nRet = obj.DPSDK_UploadFtpPic(szCameraId, timestamp, path, "ftp://" + szIp, szName, szPwd);
    if (nRet != 0)
        ShowCallRetInfo(nRet, "上传");
    else
        alert("已上传至ftp://" + szIp);
}

function ButtonGetAudioChannelsByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var ret = obj.DPSDK_GetAudioChannelsByWndNo(gWndId, nWndNo);
    document.getElementById("textAudioNum").innerText = ret;
}

function ButtonGetAudioChannelStateByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var index = document.getElementById("textAudioIndex").value;
    var ret = obj.DPSDK_GetAudioChannelStateByWndNo(gWndId, nWndNo, index);
    document.getElementById("textAudioState").innerText = (ret == true ? 1 : 0) + "";
}

function ButtonSetAudioChannelByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var index = document.getElementById("textAudioIndex").value;
    var strAudioState = document.getElementById("textAudioState").value;
    ShowCallRetInfo(obj.DPSDK_SetAudioChannelByWndNo(gWndId, nWndNo, index, strAudioState == 0 ? false : true), "设置音频状态");
}

function ButtonGetAudioChannelsByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);
    var ret = obj.DPSDK_GetAudioChannelsByHWND(hWnd);
    document.getElementById("textAudioNum").innerText = ret;
}

function ButtonGetAudioChannelStateByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);
    var index = document.getElementById("textAudioIndex").value;
    var ret = obj.DPSDK_GetAudioChannelStateByHWND(hWnd, index);
    document.getElementById("textAudioState").innerText = (ret == true ? 1 : 0) + "";
}

function ButtonSetAudioChannelByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);
    var index = document.getElementById("textAudioIndex").value;
    var strAudioState = document.getElementById("textAudioState").value;
    ShowCallRetInfo(obj.DPSDK_SetAudioChannelByHWND(hWnd, index, strAudioState == 0 ? false : true), "设置音频状态");
}

function ButtonStopRealplayByCameraId_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var strCameraID = document.getElementById("textCameraID").value;
    ShowCallRetInfo(obj.DPSDK_StopRealplayByCameraId(strCameraID), "关闭CAM");
}

function ButtonPtzDirection_onclick(nDirects) {
    var obj = document.getElementById("DPSDK_OCX");
    var szCameraId = document.getElementById("textCameraID").value;
    nDirect = nDirects;
    var nStep = document.getElementById("selectPtzDirectionStep").value;
    ShowCallRetInfo(obj.DPSDK_PtzDirection(szCameraId, nDirect, nStep, 0), "方向控制");
}

function ButtonPtzDirection_onclickStop(bStop) {
    var obj = document.getElementById("DPSDK_OCX");
    var szCameraId = document.getElementById("textCameraID").value;
    var nStep = document.getElementById("selectPtzDirectionStep").value;
    ShowCallRetInfo(obj.DPSDK_PtzDirection(szCameraId, nDirect, nStep, bStop), "方向控制");
}

function ButtonAsyncPtzDirection_onclick(nDirects) {
    var obj = document.getElementById("DPSDK_OCX");
    var szCameraId = document.getElementById("textCameraID").value;
    nDirect = nDirects;
    var nStep = document.getElementById("selectPtzDirectionStep").value;
    obj.DPSDK_AsyncPtzDirection(szCameraId, nDirect, nStep, 0);
}

function ButtonAsyncPtzDirection_onclickStop(bStop) {
    var obj = document.getElementById("DPSDK_OCX");
    var szCameraId = document.getElementById("textCameraID").value;
    var nStep = document.getElementById("selectPtzDirectionStep").value;
    obj.DPSDK_AsyncPtzDirection(szCameraId, nDirect, nStep, bStop);
}

function ButtonPtzCameraOperation_onclick(nOpers) {
    var obj = document.getElementById("DPSDK_OCX");
    var szCameraId = document.getElementById("textCameraID").value;
    nOper = nOpers;
    var nStep = document.getElementById("selectCameraStep").value;
    ShowCallRetInfo(obj.DPSDK_PtzCameraOperation(szCameraId, nOper, nStep, 0), "镜头控制");
}

function ButtonPtzCameraOperation_onclickStop(bStop) {
    var obj = document.getElementById("DPSDK_OCX");
    var szCameraId = document.getElementById("textCameraID").value;
    var nStep = document.getElementById("selectCameraStep").value;
    ShowCallRetInfo(obj.DPSDK_PtzCameraOperation(szCameraId, nOper, nStep, bStop), "镜头控制");
}

function ButtonPtzSit_onclick() {

    var obj = document.getElementById("DPSDK_OCX");

    var szCameraId = document.getElementById("textCameraID").value;
    var nXPosition = document.getElementById("textXPosition").value;
    var nYPosition = document.getElementById("textYPosition").value;
    var nStep = document.getElementById("selectPtzSitStep").value;

    ShowCallRetInfo(obj.DPSDK_PtzSit(szCameraId, nXPosition, nYPosition, nStep), "三维定位");

    var obj = document.getElementById("DPSDK_OCX");
}

function ButtonAutoPtzSit_onclick() {

    var obj = document.getElementById("DPSDK_OCX");
    var szCameraId = document.getElementById("textCameraID").value;
    var nAuto = document.getElementById("selectAutoPtzSit").value;

    ShowCallRetInfo(obj.DPSDK_PtzAutoSit(szCameraId, nAuto), "自动三维定位");

    var obj = document.getElementById("DPSDK_OCX");
}

function ButtonAddPrePoint_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var szCameraId = document.getElementById("textCameraID").value;
    var nPrePointNum = document.getElementById("textPrePointNum").value;
    var strPrePointName = document.getElementById("textPrePointName").value;
    ShowCallRetInfo(obj.DPSDK_PtzPrePointOperation(szCameraId, nPrePointNum, strPrePointName, 2), "增加预置点");
}

function ButtonDelPrePoint_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var szCameraId = document.getElementById("textCameraID").value;
    var nPrePointNum = document.getElementById("textPrePointNum").value;
    var strPrePointName = document.getElementById("textPrePointName").value;

    ShowCallRetInfo(obj.DPSDK_PtzPrePointOperation(szCameraId, nPrePointNum, strPrePointName, 3), "删除预置点");
}

function ButtonQueryPrePoint_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var szCameraId = document.getElementById("textCameraID").value;

    alert(obj.DPSDK_QueryPrePoint(szCameraId));
}

function ButtonSeekPrePoint_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var szCameraId = document.getElementById("textCameraID").value;
    var nPrePointNum = document.getElementById("textPrePointNum").value;
    var strPrePointName = document.getElementById("textPrePointName").value;

    ShowCallRetInfo(obj.DPSDK_PtzPrePointOperation(szCameraId, nPrePointNum, strPrePointName, 1), "定位预置点");
}
function getDate(strDate) {
    var date = eval('new Date(' + strDate.replace(/\d+(?=-[^-]+$)/,
        function (a) { return parseInt(a, 10) - 1; }).match(/\d+/g) + ')');
    return date;
}

function ButtonQueryRecord_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var szCameraId = document.getElementById("textCameraID").value;
    var nRecordSource = document.getElementById("selectRecordSource").value;
    var nRecordType = document.getElementById("selectRecordType").value;
    var strStartTime = document.getElementById("textStartTime").value;
    var strEndTime = document.getElementById("textEndTime").value;
    var nStartTime = getDate(strStartTime).getTime() / 1000;
    //	alert(nStartTime);
    var nEndTime = getDate(strEndTime).getTime() / 1000;
    //	alert(nEndTime);

    //    ShowCallRetInfo(obj.DPSDK_QueryRecordInfo(szCameraId, nRecordSource, nRecordType, nStartTime, nEndTime), "查询录像");

    //	gXmlRecords = obj.DPSDK_QueryRecordInfo(szCameraId, nRecordSource, nRecordType, nStartTime, nEndTime);
    alert(obj.DPSDK_QueryRecordInfo(szCameraId, nRecordSource, nRecordType, nStartTime, nEndTime));
}

function ButtonStartFilePlaybackByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var nFileIndex = document.getElementById("textFileIndex").value;
    ShowCallRetInfo(obj.DPSDK_StartFilePlaybackByWndNo(gWndId, nWndNo, nFileIndex), "按文件回放");
}

function ButtonStartFilePlaybackByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    var nFileIndex = document.getElementById("textFileIndex").value;
    ShowCallRetInfo(obj.DPSDK_StartFilePlaybackByHWND(hWnd, nFileIndex), "按文件回放");
}

function ButtonStartTimePlaybackByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var szCameraId = document.getElementById("textCameraID").value;
    var nRecordSource = document.getElementById("selectRecordSource").value;
    //   var nRecordType = document.getElementById("selectRecordType").value;
    var strStartTime = document.getElementById("textStartTime").value;
    var strEndTime = document.getElementById("textEndTime").value;
    var nStartTime = getDate(strStartTime).getTime() / 1000;
    var nEndTime = getDate(strEndTime).getTime() / 1000;

    ShowCallRetInfo(obj.DPSDK_StartTimePlaybackByWndNo(gWndId, nWndNo, szCameraId, nRecordSource, nStartTime, nEndTime), "按时间回放");
}

function ButtonStartBackTimePlaybackByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var szCameraId = document.getElementById("textCameraID").value;
    var nRecordSource = document.getElementById("selectRecordSource").value;
    //   var nRecordType = document.getElementById("selectRecordType").value;
    var strStartTime = document.getElementById("textStartTime").value;
    var strEndTime = document.getElementById("textEndTime").value;
    var nStartTime = getDate(strStartTime).getTime() / 1000;
    var nEndTime = getDate(strEndTime).getTime() / 1000;

    ShowCallRetInfo(obj.DPSDK_StartBackTimePlaybackByWndNo(gWndId, nWndNo, szCameraId, nRecordSource, nStartTime, nEndTime), "按时间倒放");
}

function ButtonStartTimePlaybackByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    var szCameraId = document.getElementById("textCameraID").value;
    var nRecordSource = document.getElementById("selectRecordSource").value;
    //   var nRecordType = document.getElementById("selectRecordType").value;
    var strStartTime = document.getElementById("textStartTime").value;
    var strEndTime = document.getElementById("textEndTime").value;
    var nStartTime = getDate(strStartTime).getTime() / 1000;
    var nEndTime = getDate(strEndTime).getTime() / 1000;

    ShowCallRetInfo(obj.DPSDK_StartTimePlaybackByHWND(hWnd, szCameraId, nRecordSource, nStartTime, nEndTime), "按时间回放");
}

function ButtonPausePlaybackByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    ShowCallRetInfo(obj.DPSDK_PausePlaybackByWndNo(gWndId, nWndNo), "暂停回放");
}

function ButtonPausePlaybackByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    ShowCallRetInfo(obj.DPSDK_PausePlaybackByHWND(hWnd), "暂停回放");
}

function ButtonResumePlaybackByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    ShowCallRetInfo(obj.DPSDK_ResumePlaybackByWndNo(gWndId, nWndNo), "继续回放");
}

function ButtonResumePlaybackByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    ShowCallRetInfo(obj.DPSDK_ResumePlaybackByHWND(hWnd), "继续回放");
}

function ButtonStopPlaybackByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    ShowCallRetInfo(obj.DPSDK_StopPlaybackByWndNo(gWndId, nWndNo), "停止回放");
}

function ButtonStopPlaybackByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    ShowCallRetInfo(obj.DPSDK_StopPlaybackByHWND(hWnd), "停止回放");
}

function ButtonSetPlaybackSpeedByWndNo_onclick(nPlaybackRate) {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    //var nPlaybackRate = document.getElementById("selectPlaybackRate").value;
    //alert(nPlaybackRate);
    var str = "设置 回放速度X" + nPlaybackRate / 8 + " ";
    ShowCallRetInfo(obj.DPSDK_SetPlaybackSpeedByWndNo(gWndId, nWndNo, nPlaybackRate), str);
}

function ButtonSetPlaybackSpeedByHWND_onclick(nPlaybackRate) {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);
    //var nPlaybackRate = document.getElementById("selectPlaybackRate").value;
    //alert(nPlaybackRate);
    var str = "设置 回放速度X" + nPlaybackRate / 8 + " ";
    ShowCallRetInfo(obj.DPSDK_SetPlaybackSpeedByHWND(hWnd, nPlaybackRate), str);
}

function ButtonDownloadRecordByFile_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var mydate = new Date();
    var reg = new RegExp(":", "g");
    gRecordPath = "c:\\dahuarecord\\" + mydate.toLocaleString().replace(" ", "").replace("年", "").replace("月", "").replace("日", "").replace(reg, "") + ".dav";
    var nFileIndex = document.getElementById("textFileIndex").value;
    alert("存储路径：" + gRecordPath);
    ShowCallRetInfo(obj.DPSDK_DownloadRecordByFile(gRecordPath, 0), "按文件下载");
}

function ButtonDownloadRecordByTime_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var szCameraId = document.getElementById("textCameraID").value;
    var nRecordSource = document.getElementById("selectRecordSource").value;
    //   var nRecordType = document.getElementById("selectRecordType").value;
    var strStartTime = document.getElementById("textStartTime").value;
    var strEndTime = document.getElementById("textEndTime").value;
    var nStartTime = getDate(strStartTime).getTime() / 1000;
    var nEndTime = getDate(strEndTime).getTime() / 1000;
    var mydate = new Date();
    var reg = new RegExp(":", "g");
    gRecordPath = "c:\\dahuarecord\\" + mydate.toLocaleString().replace(" ", "").replace("年", "").replace("月", "").replace("日", "").replace(reg, "") + ".dav";
    alert("存储路径：" + gRecordPath);
    ShowCallRetInfo(obj.DPSDK_DownloadRecordByTime(gRecordPath, szCameraId, nRecordSource, nStartTime, nEndTime), "按时间下载");
}

function ButtonPauseDownloadRecord_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var mydate = new Date();
    var reg = new RegExp(":", "g");
    //var path="c:\\dahuarecord\\"+mydate.toLocaleString().replace(" ","").replace("年","").replace("月","").replace("日","").replace(reg,"")+".dav";
    //alert("存储路径："+path);
    ShowCallRetInfo(obj.DPSDK_PauseDownloadRecord(gRecordPath), "暂停下载");
}

function ButtonResumeDownloadRecord_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var mydate = new Date();
    var reg = new RegExp(":", "g");
    //var path="c:\\dahuarecord\\"+mydate.toLocaleString().replace(" ","").replace("年","").replace("月","").replace("日","").replace(reg,"")+".dav";
    //alert("存储路径："+path);
    ShowCallRetInfo(obj.DPSDK_ResumeDownloadRecord(gRecordPath), "继续下载");
}

function ButtonStopDownloadRecord_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var mydate = new Date();
    var reg = new RegExp(":", "g");
    //var path="c:\\dahuarecord\\"+mydate.toLocaleStringtoLocaleString().replace(" ","").replace("年","").replace("月","").replace("日","").replace(reg,"")+".dav";
    //alert("存储路径："+path);
    ShowCallRetInfo(obj.DPSDK_StopDownloadRecord(gRecordPath), "停止下载");
}

function ButtonPlaybackCaptureByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var mydate = new Date();
    var reg = new RegExp(":", "g");
    var path = "c:\\dahuaphoto\\" + mydate.toLocaleString().replace(" ", "").replace("年", "").replace("月", "").replace("日", "").replace(reg, "") + ".bmp";
    alert("存储路径：" + path);
    ShowCallRetInfo(obj.DPSDK_CapturePictureByWndNo(gWndId, nWndNo, path), "抓图");
}

function ButtonPlaybackCaptureByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    var mydate = new Date();
    var reg = new RegExp(":", "g");
    var path = "c:\\dahuaphoto\\" + mydate.toLocaleString().replace(" ", "").replace("年", "").replace("月", "").replace("日", "").replace(reg, "") + ".bmp";
    alert("存储路径：" + path);
    ShowCallRetInfo(obj.DPSDK_CapturePictureByHWND(hWnd, path), "抓图");
}

function ButtonEnableAlarm_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var szDevID = document.getElementById("textDeviceID").value;
    var nVideoChannel = document.getElementById("textVideoChan").value;
    var nAlarmChannel = document.getElementById("textAlarmChan").value;
    var nAlarmType = document.getElementById("selectAlarmType2").value;

    ShowCallRetInfo(obj.DPSDK_EnableAlarm(szDevID, nVideoChannel, nAlarmChannel, nAlarmType), "布控");
}

function ButtonDisableAlarm_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    ShowCallRetInfo(obj.DPSDK_DisableAlarm(), "撤控");
}

function ButtonQueryAlarmInfo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var szCameraId = document.getElementById("textCameraID").value;
    var nAlarmType = document.getElementById("selectAlarmType").value;
    var strStartTime = document.getElementById("textAlarmStartTime").value;
    var strEndTime = document.getElementById("textAlarmEndTime").value;
    var nStartTime = getDate(strStartTime).getTime() / 1000;
    var nEndTime = getDate(strEndTime).getTime() / 1000;

    var nCount = obj.DPSDK_QueryAlarmCount(szCameraId, nAlarmType, nStartTime, nEndTime);

    if (nCount > 0) {
        var nIndex = 0;
        var strAlarmInfo = obj.DPSDK_QueryAlarmInfo(szCameraId, nAlarmType, nStartTime, nEndTime, nIndex, 500);
        alert(strAlarmInfo);
    }
    else {
        alert("无报警信息！");
    }
}


//电视墙操作方法
function getWallCount() {
    var obj = document.getElementById("DPSDK_OCX");
    var count = obj.DPSDK_QueryTvWallList();
    writewall("获取电视墙总数:" + count);
    //alert("获取电视墙总数:"+count);
}
function writewall(info) {
    document.getElementById("wallinfoxml").innerText = info;
}
function getWallInfo() {
    var obj = document.getElementById("DPSDK_OCX");
    var allstr = obj.DPSDK_GetTvWallList();
    writewall("获取电视墙信息:" + allstr);
    var xmlDoc = loadXML(allstr);
    var elements = xmlDoc.getElementsByTagName("TvWall");
    var objSelect = document.getElementById("wallid");
    objSelect.options.length = 0;
    for (var i = 0; i < elements.length; i++) {
        var tvWallId = elements[i].getAttribute("tvWallId");
        var name = elements[i].getAttribute("name");
        //var tvWallId = elements[i].getElementsByTagName("TvWall").getAttribute("tvWallId").value;
        //var name = elements[i].getElementsByTagName("name")[0].firstChild.nodeValue;
        //alert(tvWallId+"----"+name);
        var varItem = new Option(name, tvWallId);
        objSelect.options.add(varItem);
    }
}

function getWallLayout() {
    var obj = document.getElementById("DPSDK_OCX");
    var wallid = document.getElementById("wallid").value;
    //alert(wallid);
    var allstr = obj.DPSDK_QueryTvWallLayout(wallid);
    writewall("获取电视墙布局:" + allstr);
}

function getOneWallLayout() {
    var obj = document.getElementById("DPSDK_OCX");
    var wallid = document.getElementById("wallid").value;
    var wallstr = obj.DPSDK_GetTvWallLayout(wallid);
    writewall("得到电视墙布局" + wallstr);
}

function CutWall() {
    var obj = document.getElementById("DPSDK_OCX");
    var wallid = document.getElementById("wallid").value;
    var nSplitCount = document.getElementById("textSplitCount").value;
    var nScreenId = document.getElementById("textScreenId").value;
    var statue = obj.DPSDK_SetTvWallScreenSplit(wallid, nScreenId, nSplitCount);
    ShowCallRetInfo(statue, "电视墙分割");
}

function OpenWindow() {
    var obj = document.getElementById("DPSDK_OCX");
    var wallid = document.getElementById("wallid").value;
    var nScreenId = document.getElementById("textOpenWndScreenId").value;
    var fLeft = document.getElementById("textOpenWndLeft").value;
    var fTop = document.getElementById("textOpenWndTop").value;
    var fWidth = document.getElementById("textOpenWndWidth").value;
    var fHeight = document.getElementById("textOpenWndHeight").value;
    var nWndId = obj.DPSDK_TvWallScreenOpenWindow(wallid, nScreenId, fLeft, fTop, fWidth, fHeight);
    if (nWndId == -1) {
        var nLastError = obj.DPSDK_GetLastError();
        document.getElementById("RetInfo").innerText = "电视墙开窗失败！错误码：" + nLastError;
    }
    else {
        document.getElementById("RetInfo").innerText = "电视墙开窗成功！窗口ID：" + nWndId;
    }
}

function wallset() {
    var obj = document.getElementById("DPSDK_OCX");
    var wallid = document.getElementById("wallid").value;
    var nScreenId = document.getElementById("textScreenId").value;
    var szCamId = document.getElementById("textCamId").value;
    var nWinNo = document.getElementById("textWndNo").value;
    var statue = obj.DPSDK_SetTvWallScreenWindowSource(wallid, nScreenId, nWinNo, szCamId, 1, 30);
    ShowCallRetInfo(statue, "设置电视墙");
}


function wallclose() {
    var obj = document.getElementById("DPSDK_OCX");
    var wallid = document.getElementById("wallid").value;
    var nScreenId = document.getElementById("textScreenId2").value;
    var nWinNo = document.getElementById("textWndNo").value;
    var statue = obj.DPSDK_CloseTvWallScreenWindowSource(wallid, nScreenId, nWinNo);
    ShowCallRetInfo(statue, "电视墙关闭");
}


function WallClean() {
    var obj = document.getElementById("DPSDK_OCX");
    var wallid = document.getElementById("wallid").value;
    var nSplitCount = document.getElementById("textSplitCount").value;
    var nScreenId = document.getElementById("textScreenId2").value;
    var statue = obj.DPSDK_ClearTvWallScreen(wallid);
    ShowCallRetInfo(statue, "电视墙清屏");
}

function ButtonQueryPictureRecord_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var szCameraId = document.getElementById("textCameraID").value;
    var strStartTime = document.getElementById("textStartTimePicture").value;
    var strEndTime = document.getElementById("textEndTimePicture").value;
    var nStartTime = getDate(strStartTime).getTime() / 1000;
    var nEndTime = getDate(strEndTime).getTime() / 1000;
    alert(obj.DPSDK_QueryFtpPicInfo(szCameraId, nStartTime, nEndTime));
    //ShowCallRetInfo(obj.DPSDK_QueryFtpPicInfo(szCameraId,nStartTime , nEndTime), "查询");
}

function ButtonDeletePictureRecord_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var path = document.getElementById("textPicturePath").value;

    ShowCallRetInfo(obj.DPSDK_DelFtpPic(path), "删除ftp图片");
}

function ButtonCloseAudioByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    ShowCallRetInfo(obj.DPSDK_OpenAudioByWndNo(gWndId, nWndNo, false), "关闭音频");
}

function ButtonCloseAudioByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    ShowCallRetInfo(obj.DPSDK_OpenAudioByHWND(hWnd, false), "关闭音频");
}

function ButtonOpenAudioByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    ShowCallRetInfo(obj.DPSDK_OpenAudioByWndNo(gWndId, nWndNo, true), "开启音频");
}

function ButtonOpenAudioByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    ShowCallRetInfo(obj.DPSDK_OpenAudioByHWND(hWnd, true), "开启音频");
}

function ButtonStartRealRecordByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var fileSave = new ActiveXObject("MSComDlg.CommonDialog");
    fileSave.MaxFileSize = 128;
    fileSave.ShowSave();
    if (fileSave.fileName == "")
        return -1;
    ShowCallRetInfo(obj.DPSDK_StartRealRecordByWndNo(gWndId, nWndNo, fileSave.fileName), "开始录像");
}

function ButtonStartAVIRealRecordByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var fileSave = new ActiveXObject("MSComDlg.CommonDialog");
    fileSave.MaxFileSize = 128;
    fileSave.ShowSave();
    if (fileSave.fileName == "")
        return -1;
    ShowCallRetInfo(obj.DPSDK_StartAVIRealRecordByWndNo(gWndId, nWndNo, fileSave.fileName), "开始AVI格式录像");
}

function ButtonStartRealRecordByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);
    var fileSave = new ActiveXObject("MSComDlg.CommonDialog");
    fileSave.MaxFileSize = 128;
    fileSave.ShowSave();
    if (fileSave.fileName == "")
        return -1;
    ShowCallRetInfo(obj.DPSDK_StartRealRecordByHWND(hWnd, fileSave.fileName), "开始录像");
}

function ButtonStopRealRecordByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);

    ShowCallRetInfo(obj.DPSDK_StopRealRecordByWndNo(gWndId, nWndNo), "停止录像");
}

function ButtonStopRealRecordByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    ShowCallRetInfo(obj.DPSDK_StopRealRecordByHWND(hWnd), "停止录像");
}

function ButtonSetOsdTxtByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var text = document.getElementById("textOsd").value;
    //ShowCallRetInfo(obj.DPSDK_SetOsdTxtByWndNo( gWndId, nWndNo, text ), "设置Osd信息");
    ShowCallRetInfo(obj.DPSDK_SetOsdTxtExByWndNo(gWndId, nWndNo, text, 255, "黑体", 100, 70, 7, 7), "设置Osd信息");
}

function ButtonSetOsdTxtByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    var text = document.getElementById("textOsd").value;
    ShowCallRetInfo(obj.DPSDK_SetOsdTxtByHWND(hWnd, text), "设置Osd信息");
}

function ButtonCleanUpOsdInfoByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    ShowCallRetInfo(obj.DPSDK_CleanUpOsdInfoByWndNo(gWndId, nWndNo), "清除osd信息");
}

function ButtonCleanUpOsdInfoByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    ShowCallRetInfo(obj.DPSDK_CleanUpOsdInfoByHWND(hWnd), "清除osd信息");
}

function ButtonAdjustColorByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var nBrightness = document.getElementById("textBrightness").value;
    var nContract = document.getElementById("textContract").value;
    var nSaturation = document.getElementById("textSaturation").value;
    var nTone = document.getElementById("textTone").value;
    ShowCallRetInfo(obj.DPSDK_AdjustColorByWndNo(gWndId, nWndNo, nBrightness, nContract, nSaturation, nTone), "屏幕颜色调整");
}

function ButtonAdjustColorByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);

    var nBrightness = document.getElementById("textBrightness").value;
    var nContract = document.getElementById("textContract").value;
    var nSaturation = document.getElementById("textSaturation").value;
    var nTone = document.getElementById("textTone").value;
    ShowCallRetInfo(obj.DPSDK_AdjustColorByHWND(hWnd, nBrightness, nContract, nSaturation, nTone), "屏幕颜色调整");
}

function ButtonPtzLockCamera_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var szCameraId = document.getElementById("textCameraID").value;
    var nLock = document.getElementById("selectPtzLockCamera").value;

    ShowCallRetInfo(obj.DPSDK_PtzLockCamera(szCameraId, nLock), "锁定控制");
}

function ButtonStartTalk_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var szCameraId = document.getElementById("textCameraID").value;
    var nSampleType = document.getElementById("selectSampleType").value;
    var nBitType = document.getElementById("selectBitType").value;
    var nTransType = document.getElementById("selectTransType").value;
    var nAudioType = document.getElementById("selectAudioType").value;
    var nDevType = document.getElementById("selectDevType").value;

    ShowCallRetInfo(obj.DPSDK_StartTalk(szCameraId, nAudioType, nBitType, nSampleType, nDevType, nTransType), "开始语音对讲");
}

function ButtonStopTalk_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var szCameraId = document.getElementById("textCameraID").value;

    ShowCallRetInfo(obj.DPSDK_StopTalk(szCameraId), "停止语音对讲");
}

function ButtonQueryFtpPicInfo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var szCameraId = document.getElementById("textCameraID").value;

    var strStartTime = document.getElementById("textFtpStartTime").value;
    var strEndTime = document.getElementById("textFtpEndTime").value;
    var nStartTime = getDate(strStartTime).getTime() / 1000;
    var nEndTime = getDate(strEndTime).getTime() / 1000;

    alert(obj.DPSDK_QueryFtpPicInfo(szCameraId, nStartTime, nEndTime));
}

function ButtonDelFtpPic_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var strPicPath = document.getElementById("textFtpPic").value;

    ShowCallRetInfo(obj.DPSDK_DelFtpPic(strPicPath), "删除Ftp图片");
}

function ButtonStartPlaybackByLocalByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var fileSave = new ActiveXObject("MSComDlg.CommonDialog");
    fileSave.MaxFileSize = 128;
    fileSave.ShowOpen();
    if (fileSave.fileName == "")
        return -1;
    ShowCallRetInfo(obj.DPSDK_StartPlaybackByLocalByWndNo(gWndId, nWndNo, fileSave.fileName), "本地播放");
}

function ButtonStartPlaybackByLocalByHWND_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var hWnd = obj.DPSDK_GetWndVideoHandle(gWndId, nWndNo);
    var fileSave = new ActiveXObject("MSComDlg.CommonDialog");
    fileSave.MaxFileSize = 128;
    fileSave.ShowOpen();
    if (fileSave.fileName == "")
        return -1;
    ShowCallRetInfo(obj.DPSDK_StartPlaybackByLocalByHWND(hWnd, fileSave.fileName), "本地播放");
}
function ButtonSetSnapshotInterval_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var json1 = "{ \"method\":\"dms.setsnapshotinterval\",\"params\":{\"DevID\":\"";
    var json2 = document.getElementById("DevID").value;
    var json3 = "\",\"ChannelId\":";
    var json4 = document.getElementById("ChannelNo").value;
    var json5 = ",\"Interval\":";
    var json6 = document.getElementById("Interval").value;
    var json7 = "},\"id\":";
    var json8 = document.getElementById("jsonID").value;
    var json9 = " }";
    var json = json1 + json2 + json3 + json4 + json5 + json6 + json7 + json8 + json9;
    ShowCallRetInfo(obj.DPSDK_GeneralJsonTransport(json, 3, 0), "发送json");
}

function ButtonSnap_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var json1 = "{ \"method\":\"dev.snap\",\"params\":{\"DevID\":\"";
    var json2 = document.getElementById("SnapDevID").value;
    var json3 = "\",\"DevChannel\":";
    var json4 = document.getElementById("SnapChannelNo").value;
    var json5 = ",\"PicNum\":1,\"SnapType\":";
    var json6 = document.getElementById("SnapType").value;
    var json7 = ",\"CmdSrc\":1},\"id\":";
    var json8 = document.getElementById("SnapjsonID").value;
    var json9 = " }";
    var json = json1 + json2 + json3 + json4 + json5 + json6 + json7 + json8 + json9;
    ShowCallRetInfo(obj.DPSDK_GeneralJsonTransport(json, 3, 0), "发送json");
}
//{"method":"client.SetDevDirect","params":{"DevID":"1000021","channelNo":0,"stop":0,"stepX":56,"stepY":89},"id":100}
function ButtonSetCameraAngle_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var json1 = "{ \"method\":\"client.SetDevDirect\",\"params\":{\"DevID\":\"";
    var json2 = document.getElementById("AngleDevID").value;
    var json3 = "\",\"channelNo\":";
    var json4 = document.getElementById("AngleChannelNo").value;
    var json5 = ",\"stop\":0,\"stepX\":";
    var json6 = document.getElementById("AngleX").value;
    var json7 = ",\"stepY\":";
    var json8 = document.getElementById("AngleY").value;
    var json9 = "},\"id\":";
    var json10 = document.getElementById("AnglejsonID").value;
    var json11 = " }";
    var json = json1 + json2 + json3 + json4 + json5 + json6 + json7 + json8 + json9 + json10 + json11;
    ShowCallRetInfo(obj.DPSDK_GeneralJsonTransport(json, 3, 0), "发送json");
}

//{"method":"client.SetViewRange","params":{"DevID":"1000021","channelNo":0,"distance":1200,"width":500,"screenRatio":100},"id":110}
function ButtonObiectScreenRatio_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var json1 = "{ \"method\":\"client.SetViewRange\",\"params\":{\"DevID\":\"";
    var json2 = document.getElementById("ScaleDevID").value;
    var json3 = "\",\"channelNo\":";
    var json4 = document.getElementById("ScaleChannelNo").value;
    var json5 = ",\"distance\":";
    var json6 = document.getElementById("nDistance").value;
    var json7 = ",\"width\":";
    var json8 = document.getElementById("nWidth").value;
    var json9 = ",\"screenRatio\":";
    var json10 = document.getElementById("nScreenRatio").value;
    var json11 = "},\"id\":";
    var json12 = document.getElementById("ScreenRatiojsonID").value;
    var json13 = " }";
    var json = json1 + json2 + json3 + json4 + json5 + json6 + json7 + json8 + json9 + json10 + json11 + json12 + json13;
    ShowCallRetInfo(obj.DPSDK_GeneralJsonTransport(json, 3, 0), "发送json");
}

function ButtonSendGeneraljson_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var json = document.getElementById("Generaljson").value;
    var mdl = document.getElementById("selectMdl").value;
    var type = document.getElementById("selectTransportType").value;
    ShowCallRetInfo(obj.DPSDK_GeneralJsonTransport(json, mdl, type), "发送json");
}

function ButtonSubscribeAllBayCarInfo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var subType = document.getElementById("selectSubscribeAllBayCarInfo").value;
    if (subType == 1)
        ShowCallRetInfo(obj.DPSDK_SubscribeAllBayCarInfo(subType), "订阅过车流量");
    else
        ShowCallRetInfo(obj.DPSDK_SubscribeAllBayCarInfo(subType), "取消订阅过车流量");
}

function ButtonIVSSwitchByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    bIVS = !bIVS;
    ShowCallRetInfo(obj.DPSDK_SetIvsShowFlagByWndNo(gWndId, nWndNo, 1, bIVS), "规则线显示");//打开规则线显示
    ShowCallRetInfo(obj.DPSDK_SetIvsShowFlagByWndNo(gWndId, nWndNo, 2, bIVS), "目标框显示");//打开目标框显示
    ShowCallRetInfo(obj.DPSDK_SetIvsShowFlagByWndNo(gWndId, nWndNo, 3, bIVS), "轨迹线显示");//打开轨迹线显示	
}
function buttonGetExtrenUrl_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var szCameraId = document.getElementById("textCameraID").value;
    var url = obj.DPSDK_GetExternalRealStreamUrl(szCameraId, 1, 1, 1, 801, 0, 0, 0, 0, 0);
    alert(url);
}

function ButtonSetWndText_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var text = document.getElementById("WndText").value;
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    ShowCallRetInfo(obj.DPSDK_SetWndText(gWndId, nWndNo, text, "黑体", 0, 7, 7, 0, 100, 100, 100), "窗口显示文字");

}

function ButtonSetWndFullScreen_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var text = document.getElementById("WndText").value;
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    ShowCallRetInfo(obj.DPSDK_SetWndFullScreen(gWndId), "全屏显示选中窗口");
}

function ExitFullScreenTimeout() {
    var obj = document.getElementById("DPSDK_OCX");
    obj.DPSDK_ExitSmartWndFullScreen(gWndId);
}

function ButtonSetSmartWndFullScreen_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var text = document.getElementById("WndText").value;
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    ShowCallRetInfo(obj.DPSDK_SetSmartWndFullScreen(gWndId), "全屏显示Smart窗口");
    //setTimeout("ExitFullScreenTimeout()", 2000);
}

function ButtonSetWndStyle_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndStyle = document.getElementById("selectWndStyle").value;
    obj.DPSDK_SetWndStyle(nWndStyle);
}

function ButtonControlDevBurner_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var deviceid = document.getElementById("Devceid").value;
    var cmd = document.getElementById("selectcmd").value;
    var Channelid = document.getElementById("Channelid").value;
    var channelmask = 1 << Channelid;
    var nBurnerMask = document.getElementById("selectmask").value;
    var mode = document.getElementById("selectmode").value;
    var pack = document.getElementById("selectpack").value;
    ShowCallRetInfo(obj.DPSDK_ControlDevBurner(deviceid, cmd, channelmask, nBurnerMask, mode, pack), "刻录控制");
}

function ButtonGetDevBurnerCDState_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var strDeviceId = document.getElementById("Devceid_query").value;
    var nBurnId = document.getElementById("burnerId").value;
    var result = obj.DPSDK_GetDevBurnerCDState(strDeviceId, nBurnId);
    alert(result);
}

function ButtonSitPtzParam_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var szCameraId = document.getElementById("textCameraID").value;
    var nXPosition = document.getElementById("textXPositionEX").value;
    var nYPosition = document.getElementById("textYPositionEX").value;
    var nStep = document.getElementById("selectPtzSitStepEX").value;
    var nXspeed = document.getElementById("textXspeedEX").value;
    var nYspeed = document.getElementById("textYspeedEX").value;
    var nZspeed = document.getElementById("textZspeedEX").value;

    ShowCallRetInfo(obj.DPSDK_SetPtzParam(szCameraId, nXPosition, nYPosition, nStep, parseFloat(nXspeed), parseFloat(nYspeed), parseFloat(nZspeed)), "设置球机云台参数");
}

function ButtonGetPtzParam_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var szCameraId = document.getElementById("textCameraID").value;
    var type = document.getElementById("selectPtzSittype").value;
    var result = obj.DPSDK_QueryPtzSitInfo(szCameraId, type);
    alert(result);
}
function ButtonOpenDoor_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var szCameraId = document.getElementById("DoorChannelid").value;
    var result = obj.DPSDK_SetDoorCmd(szCameraId, 5);
    ShowCallRetInfo(result, "远程开门");
}

function ButtonQueryNetAlarmHostStatus_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var szDeviceId = document.getElementById("NetHostStatusDevceid").value;
    var result = obj.DPSDK_QueryNetAlarmHostStatus(szDeviceId);
    alert(result);
}

function ButtonControlNetAlarmHostCmd_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var szCameraId = document.getElementById("NetHostDevceid").value;
    var operationtype = document.getElementById("operationtype").value;
    var cmd = document.getElementById("NetHostcmd").value;
    var nStartTime = document.getElementById("NetHostStartTime").value;
    var nEndTime = document.getElementById("NetHostEndTime").value;
    var result = obj.DPSDK_ControlNetAlarmHostCmd(szCameraId, operationtype, cmd, nStartTime, nEndTime);
    ShowCallRetInfo(result, "网络报警主机控制");
}

function ButtonControlVideoAlarmHost_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var szCameraId = document.getElementById("VideoHostDevceid").value;
    var channelId = document.getElementById("VideoHostChannelNO").value;
    var controlType = document.getElementById("VideoHostcontrolType").value;

    var result = obj.DPSDK_ControlVideoAlarmHost(szCameraId, channelId, controlType);
    ShowCallRetInfo(result, "视频报警主机控制");
}

function ButtonQueryChannelViewInfo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var CameraID = document.getElementById("viewinfoCameraID").value;
    var result = obj.DPSDK_QueryChannelViewInfo(CameraID);
    alert(result);
}

function ButtonQueryDeviceViewInfo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var szDeviceId = document.getElementById("viewinfoDeviceID").value;
    var result = obj.DPSDK_QueryDeviceViewInfo(szDeviceId);

    ShowCallRetInfo(result, "查询设备球机通道可视域信息");
}

loadXML = function (xmlString) {
    var xmlDoc = null;
    //判断浏览器的类型
    //支持IE浏览器 
    if (!window.DOMParser && window.ActiveXObject) {   //window.DOMParser 判断是否是非ie浏览器
        var xmlDomVersions = ['MSXML.2.DOMDocument.6.0', 'MSXML.2.DOMDocument.3.0', 'Microsoft.XMLDOM'];
        for (var i = 0; i < xmlDomVersions.length; i++) {
            try {
                xmlDoc = new ActiveXObject(xmlDomVersions[i]);
                xmlDoc.async = false;
                xmlDoc.loadXML(xmlString); //loadXML方法载入xml字符串
                break;
            } catch (e) {
            }
        }
    }
    //支持Mozilla浏览器
    else if (window.DOMParser && document.implementation && document.implementation.createDocument) {
        try {
            /* DOMParser 对象解析 XML 文本并返回一个 XML Document 对象。
             * 要使用 DOMParser，使用不带参数的构造函数来实例化它，然后调用其 parseFromString() 方法
             * parseFromString(text, contentType) 参数text:要解析的 XML 标记 参数contentType文本的内容类型
             * 可能是 "text/xml" 、"application/xml" 或 "application/xhtml+xml" 中的一个。注意，不支持 "text/html"。
             */
            domParser = new DOMParser();
            xmlDoc = domParser.parseFromString(xmlString, 'text/xml');
        } catch (e) {
        }
    }
    else {
        return null;
    }

    return xmlDoc;
}

function ButtonCheckRealPlayAuth_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var szIP = document.getElementById("textJDIP").value;
    var nPort = document.getElementById("textJDPort").value;
    var szDvrCode = document.getElementById("textJDDvrCode").value;
    var szToken = document.getElementById("textJDToken").value;
    var nResult = obj.DPSDK_CheckRealPlayAuth(szIP, nPort, szDvrCode, szToken);
    alert("result = " + nResult);
}

function ButtonCheckPlaybackAuth_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var szIP = document.getElementById("textJDIP2").value;
    var nPort = document.getElementById("textJDPort2").value;
    var szFileId = document.getElementById("textJDFileId").value;
    var szToken = document.getElementById("textJDToken2").value;
    var nResult = obj.DPSDK_CheckPlaybackAuth(szIP, nPort, szFileId, szToken);
    //alert("result = " + nResult);
    alert(nResult);
}

function StartMonitor() {
    var obj = document.getElementById("DPSDK_OCX");
    var nResult = obj.DPSDK_StartMonitor("D:\\testdump");
    ShowCallRetInfo(nResult, "开启崩溃监控，设置dump名称D:\\testdump");
}

function StopMonitor() {
    var obj = document.getElementById("DPSDK_OCX");
    var nResult = obj.DPSDK_StopMonitor();
    ShowCallRetInfo(nResult, "关闭崩溃自动生成dump");
}

function ButtonOpenTime_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nResult = obj.DPSDK_SetSyncTimeOpen(1);
    ShowCallRetInfo(nResult, "打开全网校时");
}

function ButtonSubscribeAllBayCarInfo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nResult = obj.DPSDK_SubscribeAllBayCarInfo(1);
    ShowCallRetInfo(nResult, "订阅所有卡口过车上报");
}

function ButtonUndoSubscribe_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nResult = obj.DPSDK_SubscribeAllBayCarInfo(0);
    ShowCallRetInfo(nResult, "取消订阅所有卡口过车上报");
}

function ButtonGetChnlID_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var strChnlName = document.getElementById("ChnlName").value;
    var strChnlID = obj.DPSDK_GetChnlIDByChnlName(strChnlName);
    alert(strChnlID);
}

function ButtonQueryNVRChnlStatus_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var strDevId = document.getElementById("QueryNVRDevId").value;
    var nResult = obj.DPSDK_QueryNVRChnlStatus(strDevId);
    ShowCallRetInfo(nResult, "查询NVR通道状态");
}

function ButtonSetOsdTxt_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var strOSD = document.getElementById("textOsd").value;
    var szCameraId = document.getElementById("textCameraID").value;
    ShowCallRetInfo(obj.DPSDK_SetOSDInfo(szCameraId, strOSD, 0, 0, 5402, 797, 5402, 797, 1, 0), "摄像头码流叠加OSD信息");
}

function ButtonCleanOsdTxt_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var strOSD = "";
    var szCameraId = document.getElementById("textCameraID").value;
    ShowCallRetInfo(obj.DPSDK_SetOSDInfo(szCameraId, strOSD, 0, 0, 5402, 797, 5402, 797, 1, 0), "摄像头码流叠加OSD信息");
}

function ButtonSearchPicture_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var strChnlID = document.getElementById("ChnlID").value;
    var strStartTime = document.getElementById("searchStartTime").value;
    var strEndTime = document.getElementById("searchEndTime").value;
    var index = strChnlID.indexOf('$');
    var strDevID = strChnlID.substring(0, index);

    var jsonObj = {
        "method": "cu.searchSnapPicUrl",
        "params": {
            "DevID": "",
            "cameraId": "",
            "startTime": "",
            "endTime": ""
        },
        "id": 1
    };
    jsonObj.params.DevID = strDevID;
    jsonObj.params.cameraId = strChnlID;
    jsonObj.params.startTime = strStartTime;
    jsonObj.params.endTime = strEndTime;
    jsonObj.id = 10000;

    var jsonStr = JSON.stringify(jsonObj);

    ShowCallRetInfo(obj.DPSDK_GeneralJsonTransport(jsonStr, 1, 0), "发送json");
}

function ButtonGetPictureData_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var strPicUrl = document.getElementById("PictureFtpUrl").value;
    var strChnlID = document.getElementById("ChnlID").value;
    var index = strChnlID.indexOf('$');
    var strDevID = strChnlID.substring(0, index);

    var jsonObj = {
        "method": "dms.getSnapPic",
        "params": {
            "DevID": "",
            "FtpUrl": ""
        },
        "id": 1
    };
    jsonObj.params.DevID = strDevID;
    jsonObj.params.FtpUrl = strPicUrl;
    jsonObj.id = 30001;

    var jsonStr = JSON.stringify(jsonObj);

    ShowCallRetInfo(obj.DPSDK_GeneralJsonTransport(jsonStr, 3, 0), "发送json");
}

function ButtonStopAllPlay_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nRet = obj.DPSDK_StopAllPlay(gWndId);
    ShowCallRetInfo(nRet, "停止所有预览");
}

function ButtonGetFirstFreeWindow_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetFirstFreeWindow(gWndId);
    if (nWndNo == -1) {
        alert("无空闲窗口！");
    }
    else {
        alert("空闲窗口号：" + nWndNo);
    }
}

function ButtonStartRealplayByFreeWnd_onclick() {
    var obj = document.getElementById("DPSDK_OCX");

    var szCameraId = document.getElementById("textCameraID").value;
    var nStreamType = document.getElementById("selectStreamType").value;
    var nMediaType = document.getElementById("selectMediaType").value;
    var nTransType = document.getElementById("selectTransType").value;

    var nRet = obj.DPSDK_StartRealplayByFreeWnd(gWndId, szCameraId, nStreamType, nMediaType, nTransType);
    ShowCallRetInfo(nRet, "空闲窗口预览");
}

function ButtonGetPlayCameraIdByWndNo_onclick() {
    var obj = document.getElementById("DPSDK_OCX");
    var nWndNo = obj.DPSDK_GetSelWnd(gWndId);
    var szCameraId = obj.DPSDK_GetPlayCameraIdByWndNo(gWndId, nWndNo);
    if (szCameraId == "") {
        alert("当前窗口无对应通道ID！")
    }
    else {
        alert("窗口对应通道ID：" + szCameraId);
    }
}



//加载饼型统计图
function loadAreaChart(_id, _name, _data) {
    $('#' + _id + '').highcharts({
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false
        },
        title: {
            text: ''
        },
        tooltip: {
            headerFormat: '{series.name}<br>',
            pointFormat: '{point.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                    style: {
                        color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                    }
                }
            }
        },
        series: [{
            type: 'pie',
            name: _name,
            data: _data
        }]
    });
};

//加载柱状统计图
function loadColumnChart(_id, _name, _data) {
    $('#' + _id + '').highcharts({
        chart: {
            type: 'column'
        },
        title: {
            text: ''
        },
        subtitle: {
            text: ''
        },
        xAxis: {
            type: 'category',
            labels: {
                rotation: 0,
                style: {
                    fontSize: '13px',
                    fontFamily: 'Verdana, sans-serif'
                }
            }
        },
        yAxis: {
            min: 0,
            title: {
                text: '人数'
            }
        },
        legend: {
            enabled: false
        },
        tooltip: {
            pointFormat: '人数: <b>{point.y} </b>'
        },
        series: [{
            name: _name,
            data: _data,
            dataLabels: {
                enabled: true,
                rotation: 0,
                color: '#FFFFFF',
                align: 'center',
                //format: '{point.y:.1f}', // one decimal
                y: 30, // 10 pixels down from the top
                style: {
                    fontSize: '13px',
                    fontFamily: 'Verdana, sans-serif'
                }
            }
        }]
    });
};